208
215
CREATE TABLE worksheet_problem (
209
216
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
210
problemid INT4 REFERENCES problem (problemid) NOT NULL,
217
problemid TEXT REFERENCES problem (identifier) NOT NULL,
211
218
optional BOOLEAN,
212
219
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)
243
222
CREATE TABLE problem_attempt (
244
problemid INT4 REFERENCES problem (problemid) NOT NULL,
223
problemid VARCHAR REFERENCES problem (identifier) NOT NULL,
245
224
loginid INT4 REFERENCES login (loginid) NOT NULL,
225
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
246
226
date TIMESTAMP NOT NULL,
247
227
attempt VARCHAR NOT NULL,
248
228
complete BOOLEAN NOT NULL,
249
229
active BOOLEAN NOT NULL DEFAULT true,
250
PRIMARY KEY (problemid,loginid,date)
230
PRIMARY KEY (problemid,loginid,worksheetid,date)
253
233
CREATE TABLE problem_save (
254
problemid INT4 REFERENCES problem (problemid) NOT NULL,
234
problemid TEXT REFERENCES problem (identifier) NOT NULL,
255
235
loginid INT4 REFERENCES login (loginid) NOT NULL,
236
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
256
237
date TIMESTAMP NOT NULL,
257
238
text VARCHAR NOT NULL,
258
PRIMARY KEY (problemid,loginid)
261
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
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)
239
PRIMARY KEY (problemid,loginid, worksheetid)
242
-- TABLES FOR EXERCISES IN DATABASE --
243
CREATE TABLE test_suite (
244
suiteid SERIAL UNIQUE NOT NULL,
245
problemid TEXT REFERENCES problem (identifier) NOT NULL,
250
PRIMARY KEY (problemid, suiteid)
253
CREATE TABLE test_case (
254
testid SERIAL UNIQUE NOT NULL,
255
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
260
PRIMARY KEY (testid, suiteid)
263
CREATE TABLE suite_variables (
264
varid SERIAL PRIMARY KEY NOT NULL,
265
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
268
var_type TEXT NOT NULL,
272
CREATE TABLE test_case_parts (
273
partid SERIAL PRIMARY KEY NOT NULL,
274
testid INT4 REFERENCES test_case (testid) NOT NULL,