162
CREATE TABLE exercise (
163
identifier TEXT PRIMARY KEY,
192
CREATE TABLE problem (
193
problemid SERIAL PRIMARY KEY NOT NULL,
194
identifier VARCHAR UNIQUE NOT NULL,
172
198
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 (
199
worksheetid SERIAL PRIMARY KEY NOT NULL,
200
subject VARCHAR NOT NULL,
201
identifier VARCHAR NOT NULL,
204
UNIQUE (subject, identifier)
207
CREATE TABLE worksheet_problem (
208
worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
209
problemid INT4 REFERENCES problem (problemid) NOT NULL,
211
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
CREATE TABLE problem_attempt (
243
problemid INT4 REFERENCES problem (problemid) NOT NULL,
195
244
loginid INT4 REFERENCES login (loginid) NOT NULL,
196
ws_ex_id INT4 REFERENCES worksheet_exercise (ws_ex_id) NOT NULL,
197
245
date TIMESTAMP NOT NULL,
198
attempt TEXT NOT NULL,
246
attempt VARCHAR NOT NULL,
199
247
complete BOOLEAN NOT NULL,
200
248
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,
249
PRIMARY KEY (problemid,loginid,date)
252
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)