-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateTable.sql
59 lines (51 loc) · 1.3 KB
/
createTable.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
DROP TABLE IF EXISTS teams,
players,
games,
competitions,
events;
create table teams (
teamName varchar(30) Not Null,
yearEstablished int,
stadiumName varchar(30),
owner varchar(30),
Primary Key (teamName)
);
create table players (
playerName varchar(30) Not Null,
playerNum int Not Null,
playerTeam varchar(30) references team(teamName),
nationality varchar(30),
positionPlayed varchar(30)
);
create table games (
gameID int Not Null,
homeTeam varchar(30) references team(teamName),
awayTeam varchar(30) references team(teamName),
gameDate date,
possession decimal(4,2),
stadium varchar(30),
referee varchar(30),
shotsH int, shotsA int,
shotsOnTargetH int,
shotsOnTargetA int,
passesH int,
passesA int,
gameResult ENUM('home','away','draw'),
attendence int,
Primary Key (gameID)
);
create table competitions (
compName varchar(30) Not Null,
startYear year Not Null,
winner varchar(30),
compType ENUM('cup', 'league', 'friendly')
);
create table events (
timeOccur int check (timeOccur <= 140),
gameID int references games(gameID),
playerName varchar(30) references player(playerName),
playerNumber int references player(playerNum),
playerTeamName varchar(30) references player(playerTeam),
eventType ENUM('goal', 'yellow card', 'red card','sub in', 'sub out'),
Primary Key (gameID)
);