]>
Commit | Line | Data |
---|---|---|
1 | CREATE TABLE users ( | |
2 | id TEXT PRIMARY KEY, | |
3 | passphrase TEXT, -- NOT NULL, | |
4 | admin BOOLEAN NOT NULL DEFAULT FALSE, | |
5 | name TEXT, -- NOT NULL, | |
6 | email TEXT, -- NOT NULL, | |
7 | phone TEXT, -- NOT NULL, | |
8 | town TEXT, -- NOT NULL, | |
9 | university TEXT, -- NOT NULL, | |
10 | level TEXT, -- NOT NULL, | |
11 | country TEXT, | |
12 | lastjob BIGINT | |
13 | ); | |
14 | ||
15 | CREATE TABLE contests ( | |
16 | id TEXT PRIMARY KEY, | |
17 | name TEXT NOT NULL, | |
18 | start INT NOT NULL, | |
19 | stop INT NOT NULL, | |
20 | owner TEXT NOT NULL REFERENCES users ON DELETE CASCADE, | |
21 | CONSTRAINT positive_duration CHECK (stop > start) | |
22 | ); | |
23 | ||
24 | CREATE TABLE contest_status ( | |
25 | contest TEXT NOT NULL REFERENCES contests ON DELETE CASCADE, | |
26 | owner TEXT NOT NULL REFERENCES users ON DELETE CASCADE, | |
27 | score INT NOT NULL, | |
28 | rank INT NOT NULL, | |
29 | ||
30 | PRIMARY KEY (owner, contest) | |
31 | ); | |
32 | ||
33 | CREATE TABLE problems ( | |
34 | id TEXT PRIMARY KEY, | |
35 | author TEXT, | |
36 | writer TEXT, | |
37 | generator TEXT NOT NULL, | |
38 | judge TEXT NOT NULL, | |
39 | level TEXT NOT NULL, | |
40 | name TEXT NOT NULL, | |
41 | olimit INT, | |
42 | owner TEXT NOT NULL REFERENCES users ON DELETE CASCADE, | |
43 | private BOOLEAN NOT NULL DEFAULT FALSE, | |
44 | runner TEXT NOT NULL, | |
45 | solution TEXT , | |
46 | statement TEXT NOT NULL, | |
47 | testcnt INT NOT NULL, | |
48 | tests TEXT, | |
49 | timeout REAL NOT NULL, | |
50 | value INT NOT NULL, | |
51 | genformat TEXT, | |
52 | gensource TEXT, | |
53 | verformat TEXT, | |
54 | versource TEXT | |
55 | ); | |
56 | ||
57 | CREATE TABLE contest_problems ( | |
58 | contest TEXT REFERENCES contests ON DELETE CASCADE, | |
59 | problem TEXT NOT NULL REFERENCES problems ON DELETE CASCADE, | |
60 | PRIMARY KEY (contest, problem) | |
61 | ); | |
62 | ||
63 | CREATE TABLE jobs ( | |
64 | id SERIAL PRIMARY KEY, | |
65 | contest TEXT REFERENCES contests ON DELETE CASCADE, | |
66 | daemon TEXT, | |
67 | date BIGINT NOT NULL, | |
68 | errors TEXT, | |
69 | extension TEXT NOT NULL, | |
70 | format TEXT NOT NULL, | |
71 | private BOOLEAN NOT NULL DEFAULT FALSE, | |
72 | problem TEXT NOT NULL REFERENCES problems ON DELETE CASCADE, | |
73 | result INT, | |
74 | result_text TEXT, | |
75 | results TEXT, | |
76 | source TEXT NOT NULL, | |
77 | owner TEXT NOT NULL REFERENCES users ON DELETE CASCADE | |
78 | ); | |
79 | ||
80 | CREATE TABLE problem_status ( | |
81 | problem TEXT NOT NULL REFERENCES problems ON DELETE CASCADE, | |
82 | owner TEXT NOT NULL REFERENCES users ON DELETE CASCADE, | |
83 | job SERIAL NOT NULL REFERENCES jobs ON DELETE CASCADE, | |
84 | solved BOOLEAN NOT NULL DEFAULT FALSE, | |
85 | ||
86 | PRIMARY KEY (owner, problem) | |
87 | ); | |
88 | ||
89 | CREATE TABLE opens ( | |
90 | contest TEXT NOT NULL REFERENCES contests ON DELETE CASCADE, | |
91 | problem TEXT NOT NULL REFERENCES problems ON DELETE CASCADE, | |
92 | owner TEXT NOT NULL REFERENCES users ON DELETE CASCADE, | |
93 | time BIGINT NOT NULL, | |
94 | PRIMARY KEY (contest, problem, owner) | |
95 | ); | |
96 | ||
97 | CREATE TABLE table_comments ( | |
98 | table_name TEXT NOT NULL PRIMARY KEY, | |
99 | comment_text TEXT NOT NULL | |
100 | ); | |
101 | ||
102 | CREATE TABLE column_comments ( | |
103 | table_name TEXT NOT NULL, | |
104 | column_name TEXT NOT NULL, | |
105 | comment_text TEXT NOT NULL, | |
106 | PRIMARY KEY (table_name, column_name) | |
107 | ); | |
108 | ||
109 | INSERT INTO table_comments VALUES ('users', 'List of users'); | |
110 | INSERT INTO table_comments VALUES ('contests', 'List of contests'); | |
111 | INSERT INTO table_comments VALUES ('contest_status', 'List of (contest, user, result)'); | |
112 | INSERT INTO table_comments VALUES ('problems', 'List of problems'); | |
113 | INSERT INTO table_comments VALUES ('contest_problems', 'Many-to-many bridge between contests and problems'); | |
114 | INSERT INTO table_comments VALUES ('jobs', 'List of jobs'); | |
115 | INSERT INTO table_comments VALUES ('problem_status', 'List of (problem, user, result)'); | |
116 | INSERT INTO table_comments VALUES ('opens', 'List of (contest, problem, user, time when user opened problem)'); | |
117 | ||
118 | INSERT INTO column_comments VALUES ('users', 'passphrase', 'RFC2307-encoded passphrase'); | |
119 | INSERT INTO column_comments VALUES ('users', 'name', 'Full name of user'); | |
120 | INSERT INTO column_comments VALUES ('users', 'level', 'Highschool, Undergraduate, Master, Doctorate or Other'); | |
121 | INSERT INTO column_comments VALUES ('users', 'lastjob', 'Unix time when this user last submitted a job'); | |
122 | ||
123 | INSERT INTO column_comments VALUES ('contests', 'start', 'Unix time when contest starts'); | |
124 | INSERT INTO column_comments VALUES ('contests', 'stop', 'Unix time when contest ends'); | |
125 | ||
126 | INSERT INTO column_comments VALUES ('problems', 'author', 'Full name(s) of problem author(s)/problemsetter(s)/tester(s)/etc'); | |
127 | INSERT INTO column_comments VALUES ('problems', 'writer', 'Full name(s) of statement writer(s) (DEPRECATED)'); | |
128 | INSERT INTO column_comments VALUES ('problems', 'generator', 'Generator class, without the leading Gruntmaster::Daemon::Generator::'); | |
129 | INSERT INTO column_comments VALUES ('problems', 'runner', 'Runner class, without the leading Gruntmaster::Daemon::Runner::'); | |
130 | INSERT INTO column_comments VALUES ('problems', 'judge', 'Judge class, without the leading Gruntmaster::Daemon::Judge::'); | |
131 | INSERT INTO column_comments VALUES ('problems', 'level', 'Problem level, one of beginner, easy, medium, hard'); | |
132 | INSERT INTO column_comments VALUES ('problems', 'olimit', 'Output limit (in bytes)'); | |
133 | INSERT INTO column_comments VALUES ('problems', 'timeout', 'Time limit (in seconds)'); | |
134 | INSERT INTO column_comments VALUES ('problems', 'solution', 'Solution (HTML)'); | |
135 | INSERT INTO column_comments VALUES ('problems', 'statement', 'Statement (HTML)'); | |
136 | INSERT INTO column_comments VALUES ('problems', 'testcnt', 'Number of tests'); | |
137 | INSERT INTO column_comments VALUES ('problems', 'tests', 'JSON array of test values for ::Runner::File'); | |
138 | INSERT INTO column_comments VALUES ('problems', 'value', 'Problem value when used in a contest.'); | |
139 | INSERT INTO column_comments VALUES ('problems', 'genformat', 'Format (programming language) of the generator if using the Run generator'); | |
140 | INSERT INTO column_comments VALUES ('problems', 'gensource', 'Source code of generator if using the Run generator'); | |
141 | INSERT INTO column_comments VALUES ('problems', 'verformat', 'Format (programming language) of the verifier if using the Verifier runner'); | |
142 | INSERT INTO column_comments VALUES ('problems', 'versource', 'Source code of verifier if using the Verifier runner'); | |
143 | ||
144 | INSERT INTO column_comments VALUES ('jobs', 'daemon', 'hostname:PID of daemon that last executed this job. NULL if never executed'); | |
145 | INSERT INTO column_comments VALUES ('jobs', 'date', 'Unix time when job was submitted'); | |
146 | INSERT INTO column_comments VALUES ('jobs', 'errors', 'Compiler errors'); | |
147 | INSERT INTO column_comments VALUES ('jobs', 'extension', 'File extension of submitted program, without a leading dot'); | |
148 | INSERT INTO column_comments VALUES ('jobs', 'format', 'Format (programming language) of submitted program'); | |
149 | INSERT INTO column_comments VALUES ('jobs', 'result', 'Job result (integer constant from Gruntmaster::Daemon::Constants)'); | |
150 | INSERT INTO column_comments VALUES ('jobs', 'result_text', 'Job result (human-readable text)'); | |
151 | INSERT INTO column_comments VALUES ('jobs', 'results', 'Per-test results (JSON array of hashes with keys id (test number, counting from 1), result (integer constant from Gruntmaster::Daemon::Constants), result_text (human-readable text), time (execution time in decimal seconds))'); | |
152 | ||
153 | INSERT INTO column_comments VALUES ('problem_status', 'solved', 'True if the result is Accepted, False otherwise'); |