192
--TODO: Add in a field for the user-friendly identifier
193
193
CREATE TABLE problem (
194
identifier VARCHAR PRIMARY KEY NOT NULL,
194
problemid SERIAL PRIMARY KEY NOT NULL,
195
identifier VARCHAR UNIQUE NOT NULL,
203
--TODO: Link worksheets to offerings
204
199
CREATE TABLE worksheet (
205
200
worksheetid SERIAL PRIMARY KEY NOT NULL,
206
201
subject VARCHAR NOT NULL,
207
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
208
202
identifier VARCHAR NOT NULL,
209
203
assessable BOOLEAN,
214
208
CREATE TABLE worksheet_problem (
215
209
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
216
problemid TEXT REFERENCES problem (identifier) NOT NULL,
210
problemid INT4 REFERENCES problem (problemid) NOT NULL,
217
211
optional BOOLEAN,
218
212
PRIMARY KEY (worksheetid, problemid)
215
CREATE TABLE problem_tag (
216
problemid INT4 REFERENCES problem (problemid),
217
tag VARCHAR NOT NULL,
219
standard BOOLEAN NOT NULL,
220
added_by INT4 REFERENCES login (loginid) NOT NULL,
221
date TIMESTAMP NOT NULL,
222
PRIMARY KEY (problemid,added_by,tag)
225
CREATE TABLE problem_test_case (
226
problemid INT4 REFERENCES problem (problemid) NOT NULL,
227
testcaseid SERIAL UNIQUE NOT NULL,
230
visibility VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
233
CREATE TABLE problem_test_case_tag (
234
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
235
tag VARCHAR NOT NULL,
237
standard BOOLEAN NOT NULL,
238
added_by INT4 REFERENCES login (loginid) NOT NULL,
239
date TIMESTAMP NOT NULL,
240
PRIMARY KEY (testcaseid,added_by,tag)
221
243
CREATE TABLE problem_attempt (
222
problemid VARCHAR REFERENCES problem (identifier) NOT NULL,
244
problemid INT4 REFERENCES problem (problemid) NOT NULL,
223
245
loginid INT4 REFERENCES login (loginid) NOT NULL,
224
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
225
246
date TIMESTAMP NOT NULL,
226
247
attempt VARCHAR NOT NULL,
227
248
complete BOOLEAN NOT NULL,
232
253
CREATE TABLE problem_save (
233
254
problemid INT4 REFERENCES problem (problemid) NOT NULL,
234
255
loginid INT4 REFERENCES login (loginid) NOT NULL,
235
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
236
256
date TIMESTAMP NOT NULL,
237
257
text VARCHAR NOT NULL,
238
258
PRIMARY KEY (problemid,loginid)
241
261
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
243
CREATE TABLE test_suite (
244
suiteid SERIAL NOT NULL,
245
problemid TEXT REFERENCES problem (identifier) NOT NULL,
248
PRIMARY KEY (problemid, suiteid)
251
CREATE TABLE test_case (
252
testid SERIAL NOT NULL,
253
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
261
PRIMARY KEY (testid, suiteid)
263
CREATE TABLE problem_attempt_breakdown (
264
problemid INT4 REFERENCES problem (problemid) NOT NULL,
265
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
266
loginid INT4 REFERENCES login (loginid) NOT NULL,
267
date TIMESTAMP NOT NULL,
271
CREATE TABLE problem_prerequisite (
272
parent INT4 REFERENCES problem (problemid) NOT NULL,
273
child INT4 REFERENCES problem (problemid) NOT NULL,
274
PRIMARY KEY (parent,child)