-
Notifications
You must be signed in to change notification settings - Fork 3
/
fplModel.sql
176 lines (156 loc) · 5.44 KB
/
fplModel.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema FPL
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema FPL
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `FPL` DEFAULT CHARACTER SET latin1 ;
USE `FPL` ;
-- -----------------------------------------------------
-- Table `FPL`.`Team`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`Team` (
`id` INT NOT NULL,
`name` VARCHAR(50) NOT NULL,
`city` VARCHAR(45) NOT NULL,
`region` VARCHAR(45) NOT NULL,
`stadium` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `FPL`.`Player`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`Player` (
`pid` INT NOT NULL,
`name` VARCHAR(150) NOT NULL,
`position` VARCHAR(3) NOT NULL,
PRIMARY KEY (`pid`),
UNIQUE INDEX `pid_UNIQUE` (`pid` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `FPL`.`CurrentSeasonStats`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`CurrentSeasonStats` (
`total_points` INT NOT NULL,
`mins_played` INT NOT NULL,
`goals_scored` INT NOT NULL,
`assists` INT NOT NULL,
`clean_sheets` INT NOT NULL,
`goals_conceded` INT NOT NULL,
`own_goals` INT NOT NULL,
`penalties_saved` INT NOT NULL,
`penalties_missed` INT NOT NULL,
`yellow_cards` INT NOT NULL,
`red_cards` INT NOT NULL,
`saves` INT NOT NULL,
`ea_index` INT NOT NULL,
`influence` DOUBLE NOT NULL,
`creativity` DOUBLE NOT NULL,
`threat` DOUBLE NOT NULL,
`ict_index` DOUBLE NOT NULL,
`Player_pid` INT NOT NULL,
INDEX `fk_CurrentSeasonStats_Player1_idx` (`Player_pid` ASC),
CONSTRAINT `fk_CurrentSeasonStats_Player1`
FOREIGN KEY (`Player_pid`)
REFERENCES `FPL`.`Player` (`pid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `FPL`.`History`
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Table `FPL`.`Manager`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`Manager` (
`id` INT NOT NULL,
`name` VARCHAR(45) NOT NULL,
`birth_country` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `FPL`.`Result`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`Result` (
`id` INT NOT NULL,
`gameweek` INT,
`home_score` DOUBLE,
`away_score` DOUBLE,
`home_Team_id` VARCHAR(50) NOT NULL,
`away_Team_id` VARCHAR(50) NOT NULL,
`home_Manager_id` VARCHAR(50) NOT NULL,
`away_Manager_id` VARCHAR(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `mid_UNIQUE` (`id` ASC))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `FPL`.`TotalPastStats`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`TotalPastStats` (
`total_points` INT NOT NULL,
`mins_played` INT NOT NULL,
`goals_scored` INT NOT NULL,
`assists` INT NOT NULL,
`clean_sheets` INT NOT NULL,
`goals_conceded` INT NOT NULL,
`own_goals` INT NOT NULL,
`penalties_saved` INT NOT NULL,
`penalties_missed` INT NOT NULL,
`yellow_cards` INT NOT NULL,
`red_cards` INT NOT NULL,
`saves` INT NOT NULL,
`ea_index` INT NOT NULL,
`previous_pl_seasons` INT NOT NULL,
`Player_pid` INT NOT NULL,
INDEX `fk_PastOverallStats_Players1_idx` (`Player_pid` ASC),
CONSTRAINT `fk_PastOverallStats_Players1`
FOREIGN KEY (`Player_pid`)
REFERENCES `FPL`.`Player` (`pid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `FPL`.`PlayerResultStats`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `FPL`.`PlayerResultStats` (
`pmid` INT NOT NULL,
`points` INT NOT NULL,
`mins_played` INT NOT NULL,
`goals_scored` INT NOT NULL,
`assits` INT NOT NULL,
`clean_sheet` TINYINT(1) NOT NULL,
`goals_conceded` INT NOT NULL,
`own_goals` INT NOT NULL,
`penalties_saved` INT NOT NULL,
`penalties_missed` INT NOT NULL,
`yellow_cards` INT NOT NULL,
`red_cards` INT NOT NULL,
`saves` INT NOT NULL,
`influence` DOUBLE NOT NULL,
`creativity` DOUBLE NOT NULL,
`threat` DOUBLE NOT NULL,
`ict_index` DOUBLE NOT NULL,
`Result_id` INT NOT NULL,
`Player_pid` INT NOT NULL,
INDEX `fk_Player_has_Match_Match1_idx` (`Result_id` ASC),
INDEX `fk_Player_has_Match_Player1_idx` (`Player_pid` ASC),
UNIQUE INDEX `pmid_UNIQUE` (`pmid` ASC),
PRIMARY KEY (`pmid`),
CONSTRAINT `fk_Player_has_Match_Match1`
FOREIGN KEY (`Result_id`)
REFERENCES `FPL`.`Result` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Player_has_Match_Player1`
FOREIGN KEY (`Player_pid`)
REFERENCES `FPL`.`Player` (`pid`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;