-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathschema.sql
More file actions
97 lines (88 loc) · 2.89 KB
/
schema.sql
File metadata and controls
97 lines (88 loc) · 2.89 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
-- These are the tables that make up our database
create table if not exists user (
user_id integer not null primary key autoincrement,
username text not null unique,
passhash text not null,
passsalt text not null,
email text not null unique
);
create table if not exists status (
status_id integer not null primary key autoincrement,
status text not null unique
);
create table if not exists contest (
contest_id integer not null primary key autoincrement,
contest_name text not null unique,
start_date text not null,
end_date text not null,
organizer_id integer not null,
constraint fk_organizer
foreign key (organizer_id)
references user(user_id)
);
-- Not useful right now
create table if not exists contest_has_problem (
contest_has_problem_id integer not null primary key autoincrement,
contest_id integer not null,
problem_id integer not null,
score integer not null,
constraint fk_contest
foreign key (contest_id)
references contest(contest_id),
constraint fk_problem
foreign key (problem_id)
references problem(problem_id)
);
create table if not exists problem (
problem_id integer not null primary key autoincrement,
creator_id integer not null,
problem_name text not null,
base_score integer not null,
description text not null,
constraint fk_creator
foreign key (creator_id)
references user(user_id)
);
create table if not exists test_case (
test_case_id integer not null primary key autoincrement,
problem_id integer not null,
num_test_case integer not null,
time_limit integer not null,
expected_out blob not null,
given_input blob not null,
constraint fk_problem
foreign key (problem_id)
references problem(problem_id)
);
create table if not exists submission (
submission_id integer not null primary key autoincrement,
user_id integer not null,
status_id integer not null,
score integer not null,
date text not null,
problem_id integer not null,
constraint fk_user
foreign key (user_id)
references user(user_id),
constraint fk_status
foreign key (status_id)
references status(status_id),
constraint fk_problem
foreign key (problem_id)
references problem(problem_id)
);
create table if not exists test_case_status (
test_case_status_id integer not null primary key autoincrement,
submission_id integer not null,
test_case_id integer not null,
status_id integer not null,
constraint fk_submission
foreign key (submission_id)
references submission(submission_id),
constraint fk_test_case
foreign key (test_case_id)
references test_case(test_case_id),
constraint fk_status
foreign key (status_id)
references status(status_id)
);