-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
98 lines (88 loc) · 2.1 KB
/
database.sql
File metadata and controls
98 lines (88 loc) · 2.1 KB
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
CREATE TABLE UserModel(
id serial primary key,
email text not null,
pass_hash text not null,
token1 text not null,
token2 text not null
);
CREATE TABLE UnConfirmedUsers (
id serial primary key,
email text not null,
token1 text not null,
token2 text not null,
pass_hash text not null,
confirmed boolean
);
CREATE TABLE SessionModel (
id serial primary key,
user_id int4 not null,
token text not null,
expiry timestamp default (now() + '01:00:00'::interval),
foreign key (user_id) REFERENCES UserModel(id)
);
CREATE TABLE AdminModel (
id serial primary key,
user_id int4 not null,
priority int4 not null,
foreign key (user_id) REFERENCES UserModel(id)
);
CREATE TABLE BigOlympiadModel (
big_olympiad_id serial primary key,
name text not null,
short text not null,
logo text,
description text,
status text
);
CREATE TABLE HolderModel (
holder_id serial primary key,
name text not null,
logo text
);
CREATE TABLE OlympiadModel (
id serial primary key,
name text not null,
subject text not null,
level text not null,
img text not null,
short text not null,
big_olympiad_id int4 not null,
status text not null,
grade text not null,
holder_id int4 not null,
website text,
foreign key (big_olympiad_id) REFERENCES BigOlympiadModel(big_olympiad_id),
foreign key (holder_id) REFERENCES HolderModel(holder_id)
);
CREATE TABLE OlympiadUserModel (
id serial primary key,
olympiad_id int4,
user_id int4,
foreign key (olympiad_id) REFERENCES OlympiadModel(id),
foreign key (user_id) REFERENCES UserModel(id)
);
CREATE TABLE EventModel (
id serial primary key,
name text not null,
description text,
short text,
img text,
status text not null,
holder_id int4 not null,
website text,
foreign key (holder_id) REFERENCES HolderModel(holder_id)
);
CREATE TABLE EventUserModel (
id serial primary key,
event_id int4 not null,
user_id int4 not null,
foreign key (event_id) REFERENCES EventModel(id),
foreign key (user_id) REFERENCES UserModel(id)
);
CREATE TABLE NewsModel (
id serial primary key,
title text not null,
description text,
tablestruct text not null,
key int4 not null
);