-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfootball.sql
309 lines (281 loc) · 7.77 KB
/
football.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
----------------------------------
-- football.db SQLite version
----------------------------------
-------------------------------------
-- person.db tables
-------------------------------------
CREATE TABLE persons (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
name varchar(255) NOT NULL,
synonyms varchar (255),
code varchar(255),
born_at date,
city_id integer,
region_id integer,
country_id integer,
nationality_id integer,
created_at datetime NOT NULL,
updated_at datetime NOT NULL)
;
----------------------------------------
-- sport.db tables
----------------------------------------
CREATE TABLE assocs (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
title varchar(255) NOT NULL,
since integer,
web varchar(255),
country_id integer,
national boolean DEFAULT 'f' NOT NULL,
continental boolean DEFAULT 'f' NOT NULL,
intercontinental boolean DEFAULT 'f' NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE assocs_assocs (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
assoc1_id integer NOT NULL,
assoc2_id integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE badges (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
team_id integer NOT NULL,
league_id integer NOT NULL,
season_id integer NOT NULL,
title varchar(255) NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE events (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
league_id integer NOT NULL,
season_id integer NOT NULL,
start_at date NOT NULL,
end_at date,
team3 boolean DEFAULT 't' NOT NULL,
sources varchar(255),
config varchar(255),
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE events_grounds (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_id integer NOT NULL,
ground_id integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE events_teams (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_id integer NOT NULL,
team_id integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE games (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255),
round_id integer NOT NULL,
pos integer NOT NULL,
group_id integer,
team1_id integer NOT NULL,
team2_id integer NOT NULL,
play_at datetime NOT NULL,
postponed boolean DEFAULT 'f' NOT NULL,
play_at_v2 datetime,
play_at_v3 datetime,
ground_id integer,
city_id integer,
knockout boolean DEFAULT 'f' NOT NULL,
home boolean DEFAULT 't' NOT NULL,
score1 integer,
score2 integer,
score1et integer,
score2et integer,
score1p integer,
score2p integer,
score1i integer,
score2i integer,
score1ii integer,
score2ii integer,
next_game_id integer,
prev_game_id integer,
winner integer,
winner90 integer,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE goals (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
person_id integer NOT NULL,
game_id integer NOT NULL,
team_id integer NOT NULL,
minute integer,
offset integer DEFAULT 0 NOT NULL,
score1 integer,
score2 integer,
penalty boolean DEFAULT 'f' NOT NULL,
owngoal boolean DEFAULT 'f' NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE grounds (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
title varchar(255) NOT NULL,
synonyms varchar(255),
country_id integer NOT NULL,
city_id integer,
since integer,
capacity integer,
address varchar(255),
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE groups (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_id integer NOT NULL,
title varchar(255) NOT NULL,
pos integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE groups_teams (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
group_id integer NOT NULL,
team_id integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE leagues (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
title varchar(255) NOT NULL,
country_id integer,
club boolean DEFAULT 'f' NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE rosters (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
person_id integer NOT NULL,
team_id integer NOT NULL,
event_id integer,
pos integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE rounds (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_id integer NOT NULL,
title varchar(255) NOT NULL,
title2 varchar(255),
pos integer NOT NULL,
knockout boolean DEFAULT 'f' NOT NULL,
start_at date NOT NULL,
end_at date,
auto boolean DEFAULT 't' NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE seasons (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
title varchar(255) NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE teams (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
title varchar(255) NOT NULL,
title2 varchar(255),
code varchar(255),
synonyms varchar(255),
country_id integer NOT NULL,
city_id integer,
club boolean DEFAULT 'f' NOT NULL,
since integer,
address varchar(255),
web varchar(255),
assoc_id integer,
national boolean DEFAULT 'f' NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
----------------------------------------
-- sport.db.stats.tables
----------------------------------------
CREATE TABLE alltime_standing_entries (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
alltime_standing_id integer NOT NULL,
team_id integer NOT NULL,
pos integer,
played integer,
won integer,
lost integer,
drawn integer,
goals_for integer,
goals_against integer,
pts integer,
recs integer,
comments varchar(255),
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE alltime_standings (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
key varchar(255) NOT NULL,
title varchar(255) NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE event_standing_entries (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_standing_id integer NOT NULL,
team_id integer NOT NULL,
pos integer,
played integer,
won integer,
lost integer,
drawn integer,
goals_for integer,
goals_against integer,
pts integer,
comments varchar(255),
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE event_standings (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
event_id integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE group_standing_entries (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
group_standing_id integer NOT NULL,
team_id integer NOT NULL,
pos integer,
played integer,
won integer,
lost integer,
drawn integer,
goals_for integer,
goals_against integer,
pts integer,
comments varchar(255),
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);
CREATE TABLE group_standings (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
group_id integer NOT NULL,
created_at datetime NOT NULL,
updated_at datetime NOT NULL
);