192
193
CREATE TABLE problem (
193
problemid SERIAL PRIMARY KEY NOT NULL,
194
identifier VARCHAR UNIQUE NOT NULL,
194
identifier TEXT PRIMARY KEY,
198
203
CREATE TABLE worksheet (
199
worksheetid SERIAL PRIMARY KEY NOT NULL,
200
subject VARCHAR NOT NULL,
204
worksheetid SERIAL PRIMARY KEY,
205
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
201
206
identifier VARCHAR NOT NULL,
202
207
assessable BOOLEAN,
204
UNIQUE (subject, identifier)
209
UNIQUE (offeringid, identifier)
207
212
CREATE TABLE worksheet_problem (
208
213
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
209
problemid INT4 REFERENCES problem (problemid) NOT NULL,
214
problemid TEXT REFERENCES problem (identifier) NOT NULL,
210
215
optional BOOLEAN,
211
216
PRIMARY KEY (worksheetid, problemid)
214
CREATE TABLE problem_tag (
215
problemid INT4 REFERENCES problem (problemid),
216
tag VARCHAR NOT NULL,
218
standard BOOLEAN NOT NULL,
219
added_by INT4 REFERENCES login (loginid) NOT NULL,
220
date TIMESTAMP NOT NULL,
221
PRIMARY KEY (problemid,added_by,tag)
224
CREATE TABLE problem_test_case (
225
problemid INT4 REFERENCES problem (problemid) NOT NULL,
226
testcaseid SERIAL UNIQUE NOT NULL,
229
visibility VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
232
CREATE TABLE problem_test_case_tag (
233
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
234
tag VARCHAR NOT NULL,
236
standard BOOLEAN NOT NULL,
237
added_by INT4 REFERENCES login (loginid) NOT NULL,
238
date TIMESTAMP NOT NULL,
239
PRIMARY KEY (testcaseid,added_by,tag)
242
219
CREATE TABLE problem_attempt (
243
problemid INT4 REFERENCES problem (problemid) NOT NULL,
220
problemid TEXT REFERENCES problem (identifier) NOT NULL,
244
221
loginid INT4 REFERENCES login (loginid) NOT NULL,
222
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
245
223
date TIMESTAMP NOT NULL,
246
224
attempt VARCHAR NOT NULL,
247
225
complete BOOLEAN NOT NULL,
248
226
active BOOLEAN NOT NULL DEFAULT true,
249
PRIMARY KEY (problemid,loginid,date)
227
PRIMARY KEY (problemid,loginid,worksheetid,date)
252
230
CREATE TABLE problem_save (
253
problemid INT4 REFERENCES problem (problemid) NOT NULL,
254
loginid INT4 REFERENCES login (loginid) NOT NULL,
255
date TIMESTAMP NOT NULL,
256
text VARCHAR NOT NULL,
257
PRIMARY KEY (problemid,loginid)
260
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
262
CREATE TABLE problem_attempt_breakdown (
263
problemid INT4 REFERENCES problem (problemid) NOT NULL,
264
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
265
loginid INT4 REFERENCES login (loginid) NOT NULL,
266
date TIMESTAMP NOT NULL,
270
CREATE TABLE problem_prerequisite (
271
parent INT4 REFERENCES problem (problemid) NOT NULL,
272
child INT4 REFERENCES problem (problemid) NOT NULL,
273
PRIMARY KEY (parent,child)
231
problemid TEXT REFERENCES problem (identifier) NOT NULL,
232
loginid INT4 REFERENCES login (loginid) NOT NULL,
233
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
234
date TIMESTAMP NOT NULL,
236
PRIMARY KEY (problemid,loginid, worksheetid)
239
CREATE TABLE test_suite (
240
suiteid SERIAL PRIMARY KEY,
241
problemid TEXT REFERENCES problem (identifier) NOT NULL,
248
CREATE TABLE test_case (
249
testid SERIAL PRIMARY KEY,
250
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
257
CREATE TABLE suite_variables (
258
varid SERIAL PRIMARY KEY,
259
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
262
var_type TEXT NOT NULL,
266
CREATE TABLE test_case_parts (
267
partid SERIAL PRIMARY KEY,
268
testid INT4 REFERENCES test_case (testid) NOT NULL,
269
part_type TEXT NOT NULL,