28
28
subjectid SERIAL PRIMARY KEY NOT NULL,
29
29
subj_code VARCHAR UNIQUE NOT NULL,
30
30
subj_name VARCHAR NOT NULL,
31
subj_short_name VARCHAR UNIQUE NOT NULL
31
subj_short_name VARCHAR UNIQUE NOT NULL,
34
35
CREATE TABLE semester (
44
45
offeringid SERIAL PRIMARY KEY NOT NULL,
45
46
subject INT4 REFERENCES subject (subjectid) NOT NULL,
46
47
semesterid INTEGER REFERENCES semester (semesterid) NOT NULL,
49
48
groups_student_permissions VARCHAR NOT NULL DEFAULT 'none',
50
49
CHECK (groups_student_permissions in ('none', 'invite', 'create')),
51
50
UNIQUE (subject, semesterid)
57
56
CREATE TABLE project_set (
58
57
projectsetid SERIAL PRIMARY KEY NOT NULL,
59
58
offeringid INTEGER REFERENCES offering (offeringid) NOT NULL,
60
max_students_per_group INTEGER
59
max_students_per_group INTEGER NOT NULL DEFAULT 4
63
62
CREATE TABLE project (
64
63
projectid SERIAL PRIMARY KEY NOT NULL,
65
short_name TEXT NOT NULL,
69
66
projectsetid INTEGER REFERENCES project_set (projectsetid) NOT NULL,
70
deadline TIMESTAMP NOT NULL
73
CREATE OR REPLACE FUNCTION check_project_namespacing_insertupdate()
78
IF TG_OP = ''UPDATE'' THEN
79
IF NEW.projectsetid = OLD.projectsetid AND NEW.short_name = OLD.short_name THEN
83
SELECT offeringid INTO oid FROM project_set WHERE project_set.projectsetid = NEW.projectsetid;
84
PERFORM 1 FROM project, project_set
85
WHERE project_set.offeringid = oid AND
86
project.projectsetid = project_set.projectsetid AND
87
project.short_name = NEW.short_name;
89
RAISE EXCEPTION ''a project named % already exists in offering ID %'', NEW.short_name, oid;
95
CREATE TRIGGER check_project_namespacing
96
BEFORE INSERT OR UPDATE ON project
97
FOR EACH ROW EXECUTE PROCEDURE check_project_namespacing_insertupdate();
99
70
CREATE TABLE project_group (
100
71
groupnm VARCHAR NOT NULL,
101
72
groupid SERIAL PRIMARY KEY NOT NULL,
166
137
CREATE TABLE project_extension (
167
extensionid SERIAL PRIMARY KEY,
168
138
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL,
169
139
deadline TIMESTAMP NOT NULL,
170
140
approver INT4 REFERENCES login (loginid) NOT NULL,
174
144
CREATE TABLE project_submission (
175
submissionid SERIAL PRIMARY KEY,
176
145
assessedid INT4 REFERENCES assessed (assessedid) NOT NULL,
177
146
path VARCHAR NOT NULL,
178
revision INT4 NOT NULL,
179
date_submitted TIMESTAMP NOT NULL,
180
submitter INT4 REFERENCES login (loginid) NOT NULL
147
revision INT4 NOT NULL
183
150
CREATE TABLE project_mark (