~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),
915 by mattgiuca
Moved projectid from all tables using assessedid into the assessed table
88
    projectid   INT4 REFERENCES project (projectid) NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
89
    -- exactly one of loginid and groupid must be non-null
90
    CHECK ((loginid IS NOT NULL AND groupid IS NULL)
91
        OR (loginid IS NULL AND groupid IS NOT NULL))
92
);
93
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
94
CREATE TABLE project_extension (
391 by drtomc
Fix a couple of typos.
95
    assessedid  INT4 REFERENCES assessed (assessedid) 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
    path        VARCHAR NOT NULL,
104
    revision    INT4 NOT NULL
105
);
106
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
107
CREATE TABLE project_mark (
391 by drtomc
Fix a couple of typos.
108
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
109
    componentid INT4,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
110
    marker      INT4 REFERENCES login (loginid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
111
    mark        INT,
112
    marked      TIMESTAMP,
113
    feedback    VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
114
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
115
);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
116
117
CREATE TABLE problem (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
118
    problemid   SERIAL PRIMARY KEY NOT NULL,
659 by drtomc
Add a little script for stuffing exercises into the database.
119
    identifier  VARCHAR UNIQUE NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
120
    spec        VARCHAR
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
121
);
122
725 by mattgiuca
The database now stores a cache of all the worksheets and what problems
123
CREATE TABLE worksheet (
124
    worksheetid SERIAL PRIMARY KEY NOT NULL,
125
    subject     VARCHAR NOT NULL,
126
    identifier  VARCHAR NOT NULL,
127
    assessable  BOOLEAN,
128
    mtime       TIMESTAMP,
129
    UNIQUE (subject, identifier)
130
);
131
132
CREATE TABLE worksheet_problem (
133
    worksheetid INT4 REFERENCES worksheet (worksheetid) NOT NULL,
134
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
135
    optional    BOOLEAN,
136
    PRIMARY KEY (worksheetid, problemid)
137
);
138
353 by drtomc
Start addressing sb's suggestions.
139
CREATE TABLE problem_tag (
392 by drtomc
Fix another glitch.
140
    problemid   INT4 REFERENCES problem (problemid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
141
    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.
142
    description VARCHAR,
143
    standard    BOOLEAN NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
144
    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.
145
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
146
    PRIMARY KEY (problemid,added_by,tag)
147
);
148
149
CREATE TABLE problem_test_case (
150
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
151
    testcaseid  SERIAL UNIQUE NOT NULL,
152
    testcase    VARCHAR,
153
    description VARCHAR,
154
    visibility  VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
155
);
156
353 by drtomc
Start addressing sb's suggestions.
157
CREATE TABLE problem_test_case_tag (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
158
    testcaseid  INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
159
    tag         VARCHAR NOT NULL,
160
    description VARCHAR,
366 by drtomc
Somehow a couple of changed that address issues sb raised didn't get committed previously. Here they are.
161
    standard    BOOLEAN NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
162
    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.
163
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
164
    PRIMARY KEY (testcaseid,added_by,tag)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
165
);
166
167
CREATE TABLE problem_attempt (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
168
    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. :-)
169
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
170
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
171
    attempt     VARCHAR NOT NULL,
172
    complete    BOOLEAN NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
173
    PRIMARY KEY (problemid,loginid,date)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
174
);
175
697 by mattgiuca
users.sql: Added database table problem_save, for storing exercises that are
176
CREATE TABLE problem_save (
177
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
178
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
179
    date        TIMESTAMP NOT NULL,
180
    text        VARCHAR NOT NULL,
181
    PRIMARY KEY (problemid,loginid)
182
);
183
324 by drtomc
Should all be okay now.
184
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
185
186
CREATE TABLE problem_attempt_breakdown (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
187
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
188
    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. :-)
189
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
190
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
191
    result      BOOLEAN
192
);
193
353 by drtomc
Start addressing sb's suggestions.
194
CREATE TABLE problem_prerequisite (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
195
    parent      INT4 REFERENCES problem (problemid) NOT NULL,
196
    child       INT4 REFERENCES problem (problemid) NOT NULL,
197
    PRIMARY KEY (parent,child)
198
);
199