2
login VARCHAR UNIQUE NOT NULL,
3
loginid SERIAL PRIMARY KEY NOT NULL,
7
studentid VARCHAR -- may be null
10
CREATE TABLE offering (
11
offeringid SERIAL PRIMARY KEY NOT NULL,
12
subj_name VARCHAR NOT NULL,
13
subj_code VARCHAR NOT NULL,
14
year CHAR(4) NOT NULL,
15
semester CHAR(1) NOT NULL,
1
-- We need a users database to do authorization, manage groups, &c
6
DROP TABLE group_members;
11
login varchar(80) PRIMARY KEY, -- login id
14
studentid varchar(80) or NULL ****
18
groupid varchar(18) PRIMARY KEY, -- group name Y^4-S^9-G^3 **** use offering-id + group number (compound key)
19
nick varchar(80), -- group nickname
20
subject varchar(9), -- subject code **** use "offerings" table from CASMAS
21
year varchar(4) -- when
24
CREATE TABLE group_members (
25
login varchar(80) REFERENCES users (login),
26
groupid varchar(18) REFERENCES groups (groupid)
29
CREATE TABLE enrolment (
30
login varchar(80) REFERENCES users (login),
38
login varchar(80) REFERENCES users (login),
19
42
CREATE TABLE project (
20
projectid SERIAL PRIMARY KEY NOT NULL,
23
offeringid INT4 REFERENCES offering (offeringid) NOT NULL,
27
CREATE TABLE project_group (
28
groupnm VARCHAR NOT NULL,
29
groupid SERIAL PRIMARY KEY NOT NULL,
30
offeringid INT4 REFERENCES offering (offeringid),
32
createdby INT4 REFERENCES login (loginid) NOT NULL,
33
epoch TIMESTAMP NOT NULL,
34
UNIQUE (offeringid, groupnm)
37
CREATE TABLE group_invitation (
38
loginid INT4 REFERENCES login (loginid) NOT NULL,
39
groupid INT4 REFERENCES project_group (groupid) NOT NULL,
40
inviter INT4 REFERENCES login (loginid) NOT NULL,
41
invited TIMESTAMP NOT NULL,
43
UNIQUE (loginid,groupid)
46
CREATE TABLE group_member (
47
loginid INT4 REFERENCES login (loginid),
48
groupid INT4 REFERENCES project_group (groupid),
49
projectid INT4 REFERENCES project (projectid),
50
UNIQUE (loginid,projectid),
51
PRIMARY KEY (loginid,groupid)
54
CREATE TABLE enrolment (
55
loginid INT4 REFERENCES login (loginid),
56
offeringid INT4 REFERENCES offering (offeringid),
58
special_result VARCHAR,
60
special_supp_result VARCHAR,
62
PRIMARY KEY (loginid,offeringid)
65
CREATE TABLE assessed (
66
assessedid SERIAL PRIMARY KEY NOT NULL,
67
loginid INT4 REFERENCES login (loginid),
68
groupid INT4 REFERENCES project_group (groupid),
69
-- exactly one of loginid and groupid must be non-null
70
CHECK ((loginid IS NOT NULL AND groupid IS NULL)
71
OR (loginid IS NULL AND groupid IS NOT NULL))
74
CREATE TABLE project_extension (
75
assessedid INT4 REFERENCES assessed (assesedid) NOT NULL,
76
projectid INT4 REFERENCES project (projectid) NOT NULL,
77
deadline TIMESTAMP NOT NULL,
78
approver INT4 REFERENCES login (loginid) NOT NULL,
82
CREATE TABLE project_mark (
83
assessedid INT4 REFERENCES assessed (assesedid) NOT NULL,
84
projectid INT4 REFERENCES project (projectid) NOT NULL,
86
marker INT4 REFERENCES login (loginid) NOT NULL,
50
CREATE TABLE extension (
67
KEY: (login/groupid, projectid, componentid)
93
72
CREATE TABLE problem (
94
problemid SERIAL PRIMARY KEY NOT NULL,
98
CREATE TABLE problem_tag (
99
problemid INT4 REFERENCES tutorial_problem (problemid),
100
tag VARCHAR NOT NULL,
102
standard BOOLEAN NOT NULL,
103
added_by INT4 REFERENCES login (loginid) NOT NULL,
104
date TIMESTAMP NOT NULL,
105
PRIMARY KEY (problemid,added_by,tag)
108
CREATE TABLE problem_test_case (
109
problemid INT4 REFERENCES problem (problemid) NOT NULL,
110
testcaseid SERIAL UNIQUE NOT NULL,
113
visibility VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
116
CREATE TABLE problem_test_case_tag (
117
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
118
tag VARCHAR NOT NULL,
120
standard BOOLEAN NOT NULL,
121
added_by INT4 REFERENCES login (loginid) NOT NULL,
122
date TIMESTAMP NOT NULL,
123
PRIMARY KEY (testcaseid,added_by,tag)
78
CREATE TABLE problem_tags (
126
85
CREATE TABLE problem_attempt (
127
problemid INT4 REFERENCES problem (problemid) NOT NULL,
128
loginid INT4 REFERENCES login (loginid) NOT NULL,
129
date TIMESTAMP NOT NULL,
130
attempt VARCHAR NOT NULL,
131
complete BOOLEAN NOT NULL,
132
PRIMARY KEY (problemid,loginid,date)
91
KEY: (problemid, login, datetime)
135
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
94
CREATE INDEX indexname ON problem_attempt (problemid, login);
137
96
CREATE TABLE problem_attempt_breakdown (
138
problemid INT4 REFERENCES problem (problemid) NOT NULL,
139
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
140
loginid INT4 REFERENCES login (loginid) NOT NULL,
141
date TIMESTAMP NOT NULL,
145
CREATE TABLE problem_prerequisite (
146
parent INT4 REFERENCES problem (problemid) NOT NULL,
147
child INT4 REFERENCES problem (problemid) NOT NULL,
148
PRIMARY KEY (parent,child)
101
result (boolean) **** doesnt tell academic which concepts students are struggling with
104
CREATE TABLE problem_test_case (
107
testcase (sourced from xml)
110
tags (xref to tag table; break out)
113
# concept, curriculum, difficulty
121
# for multipart problems
122
CREATE TABLE prerequisite_problem (
129
INSERT INTO users (login,nick) values ('conway', 'Tom');
130
INSERT INTO roles (login,role) values ('conway', 'student');
131
INSERT INTO users (login,nick) values ('apeel', 'Andrew');
132
INSERT INTO roles (login,role) values ('apeel', 'student');
133
INSERT INTO users (login,nick) values ('mgiuca', 'Matt');
134
INSERT INTO roles (login,role) values ('mgiuca', 'tutor');
135
INSERT INTO users (login,nick) values ('sb', 'Steven');
136
INSERT INTO roles (login,role) values ('sb', 'lecturer');
137
INSERT INTO users (login,nick) values ('mpp', 'Mike');
138
INSERT INTO roles (login,role) values ('mpp', 'student');
139
INSERT INTO users (login,nick) values ('ivo', 'Ivo');
140
INSERT INTO roles (login,role) values ('ivo', 'admin');
142
INSERT INTO groups (groupid, nick, subject, year) values ('2007-INFO10001-321', 'Purple Alert', 'INFO10001', '2008');
143
INSERT INTO groups (groupid, nick, subject, year) values ('2007-INFO10001-322', 'Blind Illuminati', 'INFO10001', '2008');
145
INSERT INTO group_members (login,groupid) values ('conway', '2007-INFO10001-321');
146
INSERT INTO group_members (login,groupid) values ('apeel', '2007-INFO10001-321');
147
INSERT INTO group_members (login,groupid) values ('mgiuca', '2007-INFO10001-321');
148
INSERT INTO group_members (login,groupid) values ('sb', '2007-INFO10001-321');
149
INSERT INTO group_members (login,groupid) values ('mpp', '2007-INFO10001-322');
150
INSERT INTO group_members (login,groupid) values ('ivo', '2007-INFO10001-322');
152
INSERT INTO enrolment (login,subject,year) values ('conway' , 'INFO10001', '2008');
153
INSERT INTO enrolment (login,subject,year) values ('apeel' , 'INFO10001', '2008');
154
INSERT INTO enrolment (login,subject,year) values ('mgiuca' , 'INFO10001', '2008');
155
INSERT INTO enrolment (login,subject,year) values ('sb' , 'INFO10001', '2008');
156
INSERT INTO enrolment (login,subject,year) values ('mpp' , 'INFO10001', '2008');
157
INSERT INTO enrolment (login,subject,year) values ('ivo' , 'INFO10001', '2008');