162
CREATE TABLE exercise (
163
identifier TEXT PRIMARY KEY,
193
CREATE TABLE problem (
194
problemid SERIAL PRIMARY KEY NOT NULL,
195
identifier VARCHAR UNIQUE NOT NULL,
172
199
CREATE TABLE worksheet (
173
worksheetid SERIAL PRIMARY KEY,
174
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
175
identifier TEXT NOT NULL,
178
assessable BOOLEAN NOT NULL,
179
seq_no INT4 NOT NULL,
180
format TEXT NOT NUll,
181
UNIQUE (offeringid, identifier)
184
CREATE TABLE worksheet_exercise (
185
ws_ex_id SERIAL PRIMARY KEY,
186
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
187
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL,
188
seq_no INT4 NOT NULL,
189
active BOOLEAN NOT NULL DEFAULT true,
190
optional BOOLEAN NOT NULL,
191
UNIQUE (worksheetid, exerciseid)
194
CREATE TABLE exercise_attempt (
200
worksheetid SERIAL PRIMARY KEY NOT NULL,
201
subject VARCHAR NOT NULL,
202
identifier VARCHAR NOT NULL,
205
UNIQUE (subject, identifier)
208
CREATE TABLE worksheet_problem (
209
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
210
problemid INT4 REFERENCES problem (problemid) NOT NULL,
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)
243
CREATE TABLE problem_attempt (
244
problemid INT4 REFERENCES problem (problemid) NOT NULL,
195
245
loginid INT4 REFERENCES login (loginid) NOT NULL,
196
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
197
246
date TIMESTAMP NOT NULL,
198
attempt TEXT NOT NULL,
247
attempt VARCHAR NOT NULL,
199
248
complete BOOLEAN NOT NULL,
200
249
active BOOLEAN NOT NULL DEFAULT true,
201
PRIMARY KEY (loginid, ws_ex_id, date)
204
CREATE TABLE exercise_save (
205
loginid INT4 REFERENCES login (loginid) NOT NULL,
206
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
207
date TIMESTAMP NOT NULL,
209
PRIMARY KEY (loginid, ws_ex_id)
212
CREATE TABLE test_suite (
213
suiteid SERIAL PRIMARY KEY,
214
exerciseid TEXT REFERENCES exercise (identifier) NOT NULL,
221
CREATE TABLE test_case (
222
testid SERIAL PRIMARY KEY,
223
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
230
CREATE TABLE suite_variable (
231
varid SERIAL PRIMARY KEY,
232
suiteid INT4 REFERENCES test_suite (suiteid) NOT NULL,
235
var_type TEXT NOT NULL,
239
CREATE TABLE test_case_part (
240
partid SERIAL PRIMARY KEY,
241
testid INT4 REFERENCES test_case (testid) NOT NULL,
242
part_type TEXT NOT NULL,
250
PRIMARY KEY (problemid,loginid,date)
253
CREATE TABLE problem_save (
254
problemid INT4 REFERENCES problem (problemid) NOT NULL,
255
loginid INT4 REFERENCES login (loginid) NOT NULL,
256
date TIMESTAMP NOT NULL,
257
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)