forked from Echo-zzz/Football-Database
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.sql
161 lines (91 loc) · 2.39 KB
/
schemas.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
create table people(
ID INTEGER PRIMARY KEY AUTOINCREMENT
);
create table country(
ctName text primary KEY
);
create table club(
cName text PRIMARY KEY,
nickName text,
foundYear INTEGER,
ctName TEXT REFERENCES country(ctName),
officialSite text
);
create table rounds(
size INTEGER PRIMARY KEY,
numberOfRounds INTEGER
);
create table event(
eName text PRIMARY KEY,
season text,
cName TEXT REFERENCES club(cName)
);
create table friendly(
eName text PRIMARY KEY REFERENCES event(eName)
);
create table tournament(
eName text PRIMARY KEY REFERENCES event(eName)
);
create table league(
eName text PRIMARY KEY REFERENCES event(eName),
ctName text REFERENCES country(ctName),
size INTEGER REFERENCES rounds(size)
);
CREATE TABLE matchTable(
host text REFERENCES club(cName),
visit text REFERENCES club(cName),
matchDate text,
eName text REFERENCES event(eName),
awayGoals INTEGER,
homeGoals INTEGER,
awayBooks INTEGER,
homeBooks INTEGER,
PRIMARY KEY(host, visit, matchDate, eName)
);
create table match(
matchID INTEGER PRIMARY KEY AUTOINCREMENT,
matchDate INTEGER REFERENCES matchTable(matchDate),
host text REFERENCES matchTable(host),
visit text REFERENCES matchTable(visit),
eName text REFERENCES event(eName)
);
create table stadium(
sName text PRIMARY KEY,
ctName TEXT REFERENCES country(ctName),
capacity INTEGER,
yearOfBuilt INTEGER
);
create table hostStadium(
match INTEGER PRIMARY KEY REFERENCES match(matchID),
sName text REFERENCES stadium(sName)
);
create table player(
ID INTEGER PRIMARY KEY REFERENCES people(ID),
cName text REFERENCES club(cName),
pName text,
DOB TEXT
);
create table referee(
ID INTEGER PRIMARY KEY REFERENCES people(ID),
rName text
);
create table belong(
ID INTEGER REFERENCES player(ID),
ctName text REFERENCES country(ctName),
PRIMARY KEY(ID,ctName)
);
create table participate(
cName TEXT REFERENCES club(cName),
eName text REFERENCES event(eName),
PRIMARY KEY(cName, eName)
);
create table attend(
ID INTEGER REFERENCES people(ID),
matchID INTEGER REFERENCES match(matchID),
PRIMARY KEY(ID, matchID)
);
create table homeCourt(
sName text REFERENCES stadium(sName),
cName text REFERENCES club(cName),
PRIMARY KEY(sName, cName)
);