-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScheduleSystem_v2-3.sql
76 lines (64 loc) · 3.13 KB
/
ScheduleSystem_v2-3.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
drop table schedule;
drop table sections;
drop table enrollment;
drop table preferences;
drop table rooms;
drop table department;
drop table login;
drop table eventlog;
drop table distances;
create table login (userid varchar(8) NOT NULL,
password varchar(30) NOT NULL,
usertype char(1) NOT NULL,
primary key (userid));
create table distances (campus varchar(5) NOT NULL,
northdistance double NOT NULL,
southdistance double NOT NULL,
eastdistance double NOT NULL,
westdistance double NOT NULL,
primary key (campus));
create table eventlog (logid bigint NOT NULL,
datetime timestamp NOT NULL,
logitem varchar(255) NOT NULL,
primary key (logid));
create table enrollment (department varchar(10) NOT NULL,
coursenumber bigint NOT NULL,
numberenrolled smallint NOT NULL,
primary key (department, coursenumber));
create table preferences (instructor varchar(30) NOT NULL,
userid varchar(8) NOT NULL,
department varchar(10) NOT NULL,
sections smallint NOT NULL,
northcampus varchar(3),
southcampus varchar(3),
westcampus varchar(3),
eastcampus varchar(3),
weekend varchar(3),
primary key (instructor, sections),
foreign key (userid) references login(userid));
create table rooms (department varchar(10) NOT NULL,
room smallint NOT NULL,
campus varchar(5) NOT NULL,
capacity smallint NOT NULL,
mediaavailable boolean,
primary key (department, room, campus));
create table sections (callnumber bigint NOT NULL,
department varchar(10) NOT NULL,
coursenumber bigint NOT NULL,
days char(7) NOT NULL,
starttime time not null,
endtime time not null,
mediarequired varchar(3) not null,
primary key (callnumber));
create table schedule (callnumber bigint NOT NULL,
coursenumber bigint NOT NULL,
department varchar(10) NOT NULL,
days char(7) NOT NULL,
startime time NOT NULL,
endtime time NOT NULL,
instructor varchar(30) NOT NULL,
room smallint NOT NULL,
building varchar(10) NOT NULL,
primary key (callnumber),
constraint schedule_section
foreign key (callnumber) references sections(callnumber));