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