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