-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
48 lines (43 loc) · 1.31 KB
/
database.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
create table Game
(
game_id SERIAL not null,
server_id VARCHAR(255) not null,
time_started TIMESTAMP not null,
time_finished TIMESTAMP null,
primary key (game_id)
);
create table GameEvent
(
event_id SERIAL not null,
game_id SERIAL not null references Game (game_id),
event_desc VARCHAR(255) not null,
index_in_game INT not null,
is_hit BOOLEAN not null,
primary key (event_id),
unique (game_id, index_in_game)
);
create table GameEntry
(
entry_id SERIAL not null,
game_id SERIAL not null references Game (game_id),
player_id VARCHAR(255) not null,
time_won TIMESTAMP null,
primary key (entry_id),
unique (game_id, player_id)
);
create table Combo
(
combo_id SERIAL not null,
entry_id SERIAL not null references GameEntry (entry_id) on delete cascade,
index_in_entry INT not null,
primary key (combo_id),
unique (entry_id, index_in_entry)
);
create table EventInCombo
(
combo_id SERIAL not null references Combo (combo_id) on delete cascade,
event_id SERIAL not null references GameEvent (event_id),
index_in_combo INT not null,
primary key (combo_id, event_id),
unique (combo_id, event_id, index_in_combo)
);