~azzar1/unity/add-show-desktop-key

354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
1
CREATE TABLE login (
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
2
    loginid     SERIAL PRIMARY KEY NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
3
    login       VARCHAR UNIQUE NOT NULL,
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
4
    passhash    VARCHAR,
475 by mattgiuca
Commited some earlier changes to users.sql (not committed earlier due to
5
    state	VARCHAR NOT NULL CHECK (state in ('no_agreement', 'pending',
6
                                              'enabled', 'disabled')),
533 by mattgiuca
auth/authenticate: Much done!
7
    rolenm      VARCHAR NOT NULL CHECK (rolenm in ('anyone', 'student',
8
                                                   'marker', 'tutor',
9
                                                   'lecturer', 'admin')),
415 by drtomc
userdb: added a unixid field to store the uid of the user.
10
    unixid      INT UNIQUE NOT NULL, -- unix user id
475 by mattgiuca
Commited some earlier changes to users.sql (not committed earlier due to
11
    nick        VARCHAR NOT NULL,
12
    pass_exp    TIMESTAMP,
13
    acct_exp    TIMESTAMP,
14
    last_login  TIMESTAMP,
522 by drtomc
Add quite a lot of stuff to get usrmgt happening.
15
    svn_pass    VARCHAR,
462 by mattgiuca
userdb/users.sql: Added email field to login.
16
    email       VARCHAR,
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
17
    fullname    VARCHAR NOT NULL,
631 by mattgiuca
users.sql: Added "settings" field to the login table.
18
    studentid   VARCHAR, -- may be null
19
    settings    VARCHAR
25 by drtomc
A bit more work on the userdb stuff.
20
);
21
816 by mattgiuca
users.sql: Updated database schema; split subject and offering tables.
22
CREATE TABLE subject (
23
    subjectid       SERIAL PRIMARY KEY NOT NULL,
24
    subj_code       VARCHAR UNIQUE NOT NULL,
25
    subj_name       VARCHAR NOT NULL,
817 by mattgiuca
users.sql: Moved url from offering to subjects table.
26
    subj_short_name VARCHAR,    -- may be null
27
    url             VARCHAR
816 by mattgiuca
users.sql: Updated database schema; split subject and offering tables.
28
);
29
353 by drtomc
Start addressing sb's suggestions.
30
CREATE TABLE offering (
324 by drtomc
Should all be okay now.
31
    offeringid  SERIAL PRIMARY KEY NOT NULL,
816 by mattgiuca
users.sql: Updated database schema; split subject and offering tables.
32
    subject     INT4 REFERENCES subject (subjectid) NOT NULL,
324 by drtomc
Should all be okay now.
33
    year        CHAR(4) NOT NULL,
875 by mattgiuca
Added "migrations" directory, which contains incremental database update
34
    semester    CHAR(1) NOT NULL,
35
    UNIQUE (subject, year, semester)
324 by drtomc
Should all be okay now.
36
);
37
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
38
CREATE TABLE project (
39
    projectid   SERIAL PRIMARY KEY NOT NULL,
40
    synopsis    VARCHAR,
41
    url         VARCHAR,
42
    offeringid  INT4 REFERENCES offering (offeringid) NOT NULL,
43
    deadline    TIMESTAMP
44
);
45
46
CREATE TABLE project_group (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
47
    groupnm     VARCHAR NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
48
    groupid     SERIAL PRIMARY KEY NOT NULL,
353 by drtomc
Start addressing sb's suggestions.
49
    offeringid  INT4 REFERENCES offering (offeringid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
50
    nick        VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
51
    createdby   INT4 REFERENCES login (loginid) NOT NULL,
52
    epoch       TIMESTAMP NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
53
    UNIQUE (offeringid, groupnm)
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
54
);
55
353 by drtomc
Start addressing sb's suggestions.
56
CREATE TABLE group_invitation (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
57
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
58
    groupid     INT4 REFERENCES project_group (groupid) NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
59
    inviter     INT4 REFERENCES login (loginid) NOT NULL,
60
    invited     TIMESTAMP NOT NULL,
61
    accepted    TIMESTAMP,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
62
    UNIQUE (loginid,groupid)
25 by drtomc
A bit more work on the userdb stuff.
63
);
64
353 by drtomc
Start addressing sb's suggestions.
65
CREATE TABLE group_member (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
66
    loginid     INT4 REFERENCES login (loginid),
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
67
    groupid     INT4 REFERENCES project_group (groupid),
353 by drtomc
Start addressing sb's suggestions.
68
    projectid   INT4 REFERENCES project (projectid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
69
    UNIQUE (loginid,projectid),
70
    PRIMARY KEY (loginid,groupid)
25 by drtomc
A bit more work on the userdb stuff.
71
);
72
73
CREATE TABLE enrolment (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
74
    loginid     INT4 REFERENCES login (loginid),
353 by drtomc
Start addressing sb's suggestions.
75
    offeringid  INT4 REFERENCES offering (offeringid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
76
    result      INT,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
77
    special_result VARCHAR,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
78
    supp_result INT,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
79
    special_supp_result VARCHAR,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
80
    notes       VARCHAR,
81
    PRIMARY KEY (loginid,offeringid)
25 by drtomc
A bit more work on the userdb stuff.
82
);
83
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
84
CREATE TABLE assessed (
85
    assessedid  SERIAL PRIMARY KEY NOT NULL,
86
    loginid     INT4 REFERENCES login (loginid),
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
87
    groupid     INT4 REFERENCES project_group (groupid),
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
88
    -- exactly one of loginid and groupid must be non-null
89
    CHECK ((loginid IS NOT NULL AND groupid IS NULL)
90
        OR (loginid IS NULL AND groupid IS NOT NULL))
91
);
92
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
93
CREATE TABLE project_extension (
391 by drtomc
Fix a couple of typos.
94
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
353 by drtomc
Start addressing sb's suggestions.
95
    projectid   INT4 REFERENCES project (projectid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
96
    deadline    TIMESTAMP NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
97
    approver    INT4 REFERENCES login (loginid) NOT NULL,
98
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
99
);
100
665 by drtomc
userdb: Add a submission table, as per our discussions.
101
CREATE TABLE project_submission (
102
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
103
    projectid   INT4 REFERENCES project (projectid) NOT NULL,
104
    path        VARCHAR NOT NULL,
105
    revision    INT4 NOT NULL
106
);
107
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
108
CREATE TABLE project_mark (
391 by drtomc
Fix a couple of typos.
109
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
353 by drtomc
Start addressing sb's suggestions.
110
    projectid   INT4 REFERENCES project (projectid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
111
    componentid INT4,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
112
    marker      INT4 REFERENCES login (loginid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
113
    mark        INT,
114
    marked      TIMESTAMP,
115
    feedback    VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
116
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
117
);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
118
119
CREATE TABLE problem (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
120
    problemid   SERIAL PRIMARY KEY NOT NULL,
659 by drtomc
Add a little script for stuffing exercises into the database.
121
    identifier  VARCHAR UNIQUE NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
122
    spec        VARCHAR
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
123
);
124
725 by mattgiuca
The database now stores a cache of all the worksheets and what problems
125
CREATE TABLE worksheet (
126
    worksheetid SERIAL PRIMARY KEY NOT NULL,
127
    subject     VARCHAR NOT NULL,
128
    identifier  VARCHAR NOT NULL,
129
    assessable  BOOLEAN,
130
    mtime       TIMESTAMP,
131
    UNIQUE (subject, identifier)
132
);
133
134
CREATE TABLE worksheet_problem (
135
    worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
136
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
137
    optional    BOOLEAN,
138
    PRIMARY KEY (worksheetid, problemid)
139
);
140
353 by drtomc
Start addressing sb's suggestions.
141
CREATE TABLE problem_tag (
392 by drtomc
Fix another glitch.
142
    problemid   INT4 REFERENCES problem (problemid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
143
    tag         VARCHAR NOT NULL,
366 by drtomc
Somehow a couple of changed that address issues sb raised didn't get committed previously. Here they are.
144
    description VARCHAR,
145
    standard    BOOLEAN NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
146
    added_by    INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
147
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
148
    PRIMARY KEY (problemid,added_by,tag)
149
);
150
151
CREATE TABLE problem_test_case (
152
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
153
    testcaseid  SERIAL UNIQUE NOT NULL,
154
    testcase    VARCHAR,
155
    description VARCHAR,
156
    visibility  VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
157
);
158
353 by drtomc
Start addressing sb's suggestions.
159
CREATE TABLE problem_test_case_tag (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
160
    testcaseid  INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
161
    tag         VARCHAR NOT NULL,
162
    description VARCHAR,
366 by drtomc
Somehow a couple of changed that address issues sb raised didn't get committed previously. Here they are.
163
    standard    BOOLEAN NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
164
    added_by    INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
165
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
166
    PRIMARY KEY (testcaseid,added_by,tag)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
167
);
168
169
CREATE TABLE problem_attempt (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
170
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
171
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
172
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
173
    attempt     VARCHAR NOT NULL,
174
    complete    BOOLEAN NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
175
    PRIMARY KEY (problemid,loginid,date)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
176
);
177
697 by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are
178
CREATE TABLE problem_save (
179
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
180
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
181
    date        TIMESTAMP NOT NULL,
182
    text        VARCHAR NOT NULL,
183
    PRIMARY KEY (problemid,loginid)
184
);
185
324 by drtomc
Should all be okay now.
186
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
187
188
CREATE TABLE problem_attempt_breakdown (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
189
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
190
    testcaseid  INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
191
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
192
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
193
    result      BOOLEAN
194
);
195
353 by drtomc
Start addressing sb's suggestions.
196
CREATE TABLE problem_prerequisite (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
197
    parent      INT4 REFERENCES problem (problemid) NOT NULL,
198
    child       INT4 REFERENCES problem (problemid) NOT NULL,
199
    PRIMARY KEY (parent,child)
200
);
201