10
10
CREATE TABLE users (
11
login varchar(80) PRIMARY KEY, -- login id
14
studentid varchar(80) or NULL ****
11
login VARCHAR UNIQUE NOT NULL,
12
loginid SERIAL PRIMARY KEY NOT NULL,
15
studentid VARCHAR, -- may be null
17
18
CREATE TABLE groups (
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
19
group VARCHAR NOT NULL,
20
groupid SERIAL PRIMARY KEY NOT NULL,
21
offeringid INT4 REFERENCES offerings (offeringid),
23
UNIQUE (offeringid, group)
26
CREATE TABLE group_invitations (
27
loginid INT4 REFERENCES users (loginid),
28
groupid INT4 REFERENCES groups (groupid),
29
UNIQUE (loginid,groupid)
24
32
CREATE TABLE group_members (
25
login varchar(80) REFERENCES users (login),
26
groupid varchar(18) REFERENCES groups (groupid)
33
loginid INT4 REFERENCES users (loginid),
34
groupid INT4 REFERENCES groups (groupid),
35
projectid INT4 REFERENCES projects (projectid),
36
UNIQUE (loginid,projectid),
37
PRIMARY KEY (loginid,groupid)
29
40
CREATE TABLE enrolment (
30
login varchar(80) REFERENCES users (login),
41
loginid INT4 REFERENCES users (loginid),
42
offeringid INT4 REFERENCES offerings (offeringid),
46
PRIMARY KEY (loginid,offeringid)
37
49
CREATE TABLE roles (
38
login varchar(80) REFERENCES users (login),
42
CREATE TABLE project (
50
CREATE TABLE extension (
67
KEY: (login/groupid, projectid, componentid)
50
loginid INT4 PRIMARY KEY REFERENCES users (loginid),
54
CREATE TABLE projects (
55
projectid SERIAL PRIMARY KEY NOT NULL,
58
offeringid INT4 REFERENCES offerings (offeringid) NOT NULL,
62
CREATE TABLE project_extension (
64
projectid INT4 REFERENCES projects (projectid) NOT NULL,
65
deadline TIMESTAMP NOT NULL,
66
approver INT4 REFERENCES users (loginid) NOT NULL,
70
CREATE TABLE project_mark (
72
projectid INT4 REFERENCES projects (projectid) NOT NULL,
74
marker INT4 REFERENCES users (loginid) NOT NULL,
79
PRIMARY KEY (loginid/groupid, projectid, componentid)
72
82
CREATE TABLE problem (
83
problemid SERIAL PRIMARY KEY NOT NULL,
78
87
CREATE TABLE problem_tags (
88
problemid INT4 REFERENCES tutorial_problem (problemid),
90
added_by INT4 REFERENCES users (loginid) NOT NULL,
91
when TIMESTAMP NOT NULL,
92
PRIMARY KEY (problemid,added_by,tag)
95
CREATE TABLE problem_test_case (
96
problemid INT4 REFERENCES problem (problemid) NOT NULL,
97
testcaseid SERIAL UNIQUE NOT NULL,
100
visibility VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
103
CREATE TABLE problem_test_case_tags (
104
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
105
tag VARCHAR NOT NULL,
107
added_by INT4 REFERENCES users (loginid) NOT NULL,
108
when TIMESTAMP NOT NULL,
109
PRIMARY KEY (testcaseid,added_by,tag)
85
112
CREATE TABLE problem_attempt (
91
KEY: (problemid, login, datetime)
113
problemid INT4 REFERENCES problem (problemid) NOT NULL,
114
loginid INT4 REFERENCES users (loginid) NOT NULL,
115
when TIMESTAMP NOT NULL,
116
attempt VARCHAR NOT NULL,
117
complete BOOLEAN NOT NULL,
118
PRIMARY KEY (problemid,loginid,when)
94
121
CREATE INDEX indexname ON problem_attempt (problemid, login);
96
123
CREATE TABLE problem_attempt_breakdown (
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');
124
problemid INT4 REFERENCES problem (problemid) NOT NULL,
125
testcaseid INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
126
loginid INT4 REFERENCES users (loginid) NOT NULL,
127
when TIMESTAMP NOT NULL,
131
CREATE TABLE problem_prerequisites (
132
parent INT4 REFERENCES problem (problemid) NOT NULL,
133
child INT4 REFERENCES problem (problemid) NOT NULL,
134
PRIMARY KEY (parent,child)