~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,
5
    state	VARCHAR NOT NULL CHECK (state in ('no_agreement', 'enabled', 'disabled')),
415 by drtomc
userdb: added a unixid field to store the uid of the user.
6
    unixid      INT UNIQUE NOT NULL, -- unix user id
446 by drtomc
users.sql: constrain the rolenm to be from a given set of roles.
7
    nick        VARCHAR NOT NULL,
8
    fullname    VARCHAR NOT NULL,
9
    rolenm      VARCHAR NOT NULL CHECK (rolenm in ('anyone', 'student', 'tutor', 'lecturer', 'admin')),
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
10
    studentid   VARCHAR -- may be null
25 by drtomc
A bit more work on the userdb stuff.
11
);
12
353 by drtomc
Start addressing sb's suggestions.
13
CREATE TABLE offering (
324 by drtomc
Should all be okay now.
14
    offeringid  SERIAL PRIMARY KEY NOT NULL,
15
    subj_name   VARCHAR NOT NULL,
16
    subj_code   VARCHAR NOT NULL,
17
    year        CHAR(4) NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
18
    semester    CHAR(1) NOT NULL,
19
    url         VARCHAR
324 by drtomc
Should all be okay now.
20
);
21
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
22
CREATE TABLE project (
23
    projectid   SERIAL PRIMARY KEY NOT NULL,
24
    synopsis    VARCHAR,
25
    url         VARCHAR,
26
    offeringid  INT4 REFERENCES offering (offeringid) NOT NULL,
27
    deadline    TIMESTAMP
28
);
29
30
CREATE TABLE project_group (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
31
    groupnm     VARCHAR NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
32
    groupid     SERIAL PRIMARY KEY NOT NULL,
353 by drtomc
Start addressing sb's suggestions.
33
    offeringid  INT4 REFERENCES offering (offeringid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
34
    nick        VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
35
    createdby   INT4 REFERENCES login (loginid) NOT NULL,
36
    epoch       TIMESTAMP NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
37
    UNIQUE (offeringid, groupnm)
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
38
);
39
353 by drtomc
Start addressing sb's suggestions.
40
CREATE TABLE group_invitation (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
41
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
42
    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. :-)
43
    inviter     INT4 REFERENCES login (loginid) NOT NULL,
44
    invited     TIMESTAMP NOT NULL,
45
    accepted    TIMESTAMP,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
46
    UNIQUE (loginid,groupid)
25 by drtomc
A bit more work on the userdb stuff.
47
);
48
353 by drtomc
Start addressing sb's suggestions.
49
CREATE TABLE group_member (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
50
    loginid     INT4 REFERENCES login (loginid),
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
51
    groupid     INT4 REFERENCES project_group (groupid),
353 by drtomc
Start addressing sb's suggestions.
52
    projectid   INT4 REFERENCES project (projectid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
53
    UNIQUE (loginid,projectid),
54
    PRIMARY KEY (loginid,groupid)
25 by drtomc
A bit more work on the userdb stuff.
55
);
56
57
CREATE TABLE enrolment (
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
58
    loginid     INT4 REFERENCES login (loginid),
353 by drtomc
Start addressing sb's suggestions.
59
    offeringid  INT4 REFERENCES offering (offeringid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
60
    result      INT,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
61
    special_result VARCHAR,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
62
    supp_result INT,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
63
    special_supp_result VARCHAR,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
64
    notes       VARCHAR,
65
    PRIMARY KEY (loginid,offeringid)
25 by drtomc
A bit more work on the userdb stuff.
66
);
67
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
68
CREATE TABLE assessed (
69
    assessedid  SERIAL PRIMARY KEY NOT NULL,
70
    loginid     INT4 REFERENCES login (loginid),
355 by drtomc
Fix a few typos and glitches to actually create the ivle database.
71
    groupid     INT4 REFERENCES project_group (groupid),
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
72
    -- exactly one of loginid and groupid must be non-null
73
    CHECK ((loginid IS NOT NULL AND groupid IS NULL)
74
        OR (loginid IS NULL AND groupid IS NOT NULL))
75
);
76
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
77
CREATE TABLE project_extension (
391 by drtomc
Fix a couple of typos.
78
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
353 by drtomc
Start addressing sb's suggestions.
79
    projectid   INT4 REFERENCES project (projectid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
80
    deadline    TIMESTAMP NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
81
    approver    INT4 REFERENCES login (loginid) NOT NULL,
82
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
83
);
84
85
CREATE TABLE project_mark (
391 by drtomc
Fix a couple of typos.
86
    assessedid  INT4 REFERENCES assessed (assessedid) NOT NULL,
353 by drtomc
Start addressing sb's suggestions.
87
    projectid   INT4 REFERENCES project (projectid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
88
    componentid INT4,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
89
    marker      INT4 REFERENCES login (loginid) NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
90
    mark        INT,
91
    marked      TIMESTAMP,
92
    feedback    VARCHAR,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
93
    notes       VARCHAR
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
94
);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
95
96
CREATE TABLE problem (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
97
    problemid   SERIAL PRIMARY KEY NOT NULL,
98
    spec        VARCHAR
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
99
);
100
353 by drtomc
Start addressing sb's suggestions.
101
CREATE TABLE problem_tag (
392 by drtomc
Fix another glitch.
102
    problemid   INT4 REFERENCES problem (problemid),
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
103
    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.
104
    description VARCHAR,
105
    standard    BOOLEAN NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
106
    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.
107
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
108
    PRIMARY KEY (problemid,added_by,tag)
109
);
110
111
CREATE TABLE problem_test_case (
112
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
113
    testcaseid  SERIAL UNIQUE NOT NULL,
114
    testcase    VARCHAR,
115
    description VARCHAR,
116
    visibility  VARCHAR CHECK (visibility in ('public', 'protected', 'private'))
117
);
118
353 by drtomc
Start addressing sb's suggestions.
119
CREATE TABLE problem_test_case_tag (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
120
    testcaseid  INT4 REFERENCES problem_test_case (testcaseid) NOT NULL,
121
    tag         VARCHAR NOT NULL,
122
    description VARCHAR,
366 by drtomc
Somehow a couple of changed that address issues sb raised didn't get committed previously. Here they are.
123
    standard    BOOLEAN NOT NULL,
354 by drtomc
Addressed the rest of sb's suggestions. No doubt this will lead to more suggestions. :-)
124
    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.
125
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
126
    PRIMARY KEY (testcaseid,added_by,tag)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
127
);
128
129
CREATE TABLE problem_attempt (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
130
    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. :-)
131
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
132
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
133
    attempt     VARCHAR NOT NULL,
134
    complete    BOOLEAN NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
135
    PRIMARY KEY (problemid,loginid,date)
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
136
);
137
324 by drtomc
Should all be okay now.
138
CREATE INDEX problem_attempt_index ON problem_attempt (problemid, loginid);
281 by stevenbird
extensive updates based on data modelling discussion with Tom Conway
139
140
CREATE TABLE problem_attempt_breakdown (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
141
    problemid   INT4 REFERENCES problem (problemid) NOT NULL,
142
    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. :-)
143
    loginid     INT4 REFERENCES login (loginid) NOT NULL,
319 by drtomc
Partial correctness for the user database schema. A few bits and pieces to go.
144
    date        TIMESTAMP NOT NULL,
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
145
    result      BOOLEAN
146
);
147
353 by drtomc
Start addressing sb's suggestions.
148
CREATE TABLE problem_prerequisite (
296 by drtomc
Almost SQLized the database stuff from yesterday's discussion with sb.
149
    parent      INT4 REFERENCES problem (problemid) NOT NULL,
150
    child       INT4 REFERENCES problem (problemid) NOT NULL,
151
    PRIMARY KEY (parent,child)
152
);
153