25
by drtomc
A bit more work on the userdb stuff. |
1 |
-- We need a users database to do authorization, manage groups, &c
|
2 |
-- Here's a first cut.
|
|
3 |
||
4 |
DROP TABLE roles; |
|
5 |
DROP TABLE enrolment; |
|
6 |
DROP TABLE group_members; |
|
7 |
DROP TABLE users; |
|
8 |
DROP TABLE groups; |
|
9 |
||
10 |
CREATE TABLE users ( |
|
11 |
login varchar(80) PRIMARY KEY, -- login id |
|
12 |
nick varchar(80) |
|
13 |
);
|
|
14 |
||
15 |
CREATE TABLE groups ( |
|
16 |
groupid varchar(18) PRIMARY KEY, -- group name Y^4-S^9-G^3 |
|
17 |
nick varchar(80), -- group nickname |
|
18 |
subject varchar(9), -- subject code |
|
19 |
year varchar(4) -- when |
|
20 |
);
|
|
21 |
||
22 |
CREATE TABLE group_members ( |
|
23 |
login varchar(80) REFERENCES users (login), |
|
24 |
groupid varchar(18) REFERENCES groups (groupid) |
|
25 |
);
|
|
26 |
||
27 |
CREATE TABLE enrolment ( |
|
28 |
login varchar(80) REFERENCES users (login), |
|
29 |
subject varchar(9), |
|
30 |
year varchar(4) |
|
31 |
);
|
|
32 |
||
33 |
CREATE TABLE roles ( |
|
34 |
login varchar(80) REFERENCES users (login), |
|
35 |
role varchar(8) |
|
36 |
);
|
|
37 |
||
38 |
INSERT INTO users (login,nick) values ('conway', 'Tom'); |
|
39 |
INSERT INTO roles (login,role) values ('conway', 'student'); |
|
40 |
INSERT INTO users (login,nick) values ('apeel', 'Andrew'); |
|
41 |
INSERT INTO roles (login,role) values ('apeel', 'student'); |
|
42 |
INSERT INTO users (login,nick) values ('mgiuca', 'Matt'); |
|
43 |
INSERT INTO roles (login,role) values ('mgiuca', 'tutor'); |
|
44 |
INSERT INTO users (login,nick) values ('sb', 'Steven'); |
|
45 |
INSERT INTO roles (login,role) values ('sb', 'lecturer'); |
|
46 |
INSERT INTO users (login,nick) values ('mpp', 'Mike'); |
|
47 |
INSERT INTO roles (login,role) values ('mpp', 'student'); |
|
48 |
INSERT INTO users (login,nick) values ('ivo', 'Ivo'); |
|
49 |
INSERT INTO roles (login,role) values ('ivo', 'admin'); |
|
50 |
||
51 |
INSERT INTO groups (groupid, nick, subject, year) values ('2007-INFO10001-321', 'Purple Alert', 'INFO10001', '2008'); |
|
52 |
INSERT INTO groups (groupid, nick, subject, year) values ('2007-INFO10001-322', 'Blind Illuminati', 'INFO10001', '2008'); |
|
53 |
||
54 |
INSERT INTO group_members (login,groupid) values ('conway', '2007-INFO10001-321'); |
|
55 |
INSERT INTO group_members (login,groupid) values ('apeel', '2007-INFO10001-321'); |
|
56 |
INSERT INTO group_members (login,groupid) values ('mgiuca', '2007-INFO10001-321'); |
|
57 |
INSERT INTO group_members (login,groupid) values ('sb', '2007-INFO10001-321'); |
|
58 |
INSERT INTO group_members (login,groupid) values ('mpp', '2007-INFO10001-322'); |
|
59 |
INSERT INTO group_members (login,groupid) values ('ivo', '2007-INFO10001-322'); |
|
60 |
||
61 |
INSERT INTO enrolment (login,subject,year) values ('conway' , 'INFO10001', '2008'); |
|
62 |
INSERT INTO enrolment (login,subject,year) values ('apeel' , 'INFO10001', '2008'); |
|
63 |
INSERT INTO enrolment (login,subject,year) values ('mgiuca' , 'INFO10001', '2008'); |
|
64 |
INSERT INTO enrolment (login,subject,year) values ('sb' , 'INFO10001', '2008'); |
|
65 |
INSERT INTO enrolment (login,subject,year) values ('mpp' , 'INFO10001', '2008'); |
|
66 |
INSERT INTO enrolment (login,subject,year) values ('ivo' , 'INFO10001', '2008'); |