4
DROP TABLE group_members;
9
login varchar(80) PRIMARY KEY, -- login id
14
groupid varchar(18) PRIMARY KEY, -- group name Y^4-S^9-G^3
15
nick varchar(80), -- group nickname
16
subject varchar(9), -- subject code
17
year varchar(4) -- when
20
CREATE TABLE group_members (
21
login varchar(80) REFERENCES users (login),
22
groupid varchar(18) REFERENCES groups (groupid)
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,
19
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)
25
54
CREATE TABLE enrolment (
26
login varchar(80) REFERENCES users (login),
32
login varchar(80) REFERENCES users (login),
36
INSERT INTO users (login,nick) values ('conway', 'Tom');
37
INSERT INTO roles (login,role) values ('conway', 'student');
38
INSERT INTO users (login,nick) values ('apeel', 'Andrew');
39
INSERT INTO roles (login,role) values ('apeel', 'student');
40
INSERT INTO users (login,nick) values ('mgiuca', 'Matt');
41
INSERT INTO roles (login,role) values ('mgiuca', 'tutor');
42
INSERT INTO users (login,nick) values ('sb', 'Steven');
43
INSERT INTO roles (login,role) values ('sb', 'lecturer');
44
INSERT INTO users (login,nick) values ('mpp', 'Mike');
45
INSERT INTO roles (login,role) values ('mpp', 'student');
46
INSERT INTO users (login,nick) values ('ivo', 'Ivo');
47
INSERT INTO roles (login,role) values ('ivo', 'admin');
49
INSERT INTO groups (groupid, nick, subject, year) values ('2007-INFO10001-321', 'Purple Alert', 'INFO10001', '2008');
50
INSERT INTO groups (groupid, nick, subject, year) values ('2007-INFO10001-322', 'Blind Illuminati', 'INFO10001', '2008');
52
INSERT INTO group_members (login,groupid) values ('conway', '2007-INFO10001-321');
53
INSERT INTO group_members (login,groupid) values ('apeel', '2007-INFO10001-321');
54
INSERT INTO group_members (login,groupid) values ('mgiuca', '2007-INFO10001-321');
55
INSERT INTO group_members (login,groupid) values ('sb', '2007-INFO10001-321');
56
INSERT INTO group_members (login,groupid) values ('mpp', '2007-INFO10001-322');
57
INSERT INTO group_members (login,groupid) values ('ivo', '2007-INFO10001-322');
59
INSERT INTO enrolment (login,subject,year) values ('conway' , 'INFO10001', '2008');
60
INSERT INTO enrolment (login,subject,year) values ('apeel' , 'INFO10001', '2008');
61
INSERT INTO enrolment (login,subject,year) values ('mgiuca' , 'INFO10001', '2008');
62
INSERT INTO enrolment (login,subject,year) values ('sb' , 'INFO10001', '2008');
63
INSERT INTO enrolment (login,subject,year) values ('mpp' , 'INFO10001', '2008');
64
INSERT INTO enrolment (login,subject,year) values ('ivo' , 'INFO10001', '2008');
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,
93
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)
126
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)
135
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
137
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)