forked from ebenezerjeya/ApptApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqlqueries.txt
104 lines (94 loc) · 4.54 KB
/
sqlqueries.txt
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
CREATE TABLE STUDENT_INFO (
Student_ID varchar(9) NOT NULL,
Student_FName varchar(50) NOT NULL,
Student_LName varchar(50) NOT NULL,
Student_Email varchar(17) NOT NULL,
Student_Password varchar(35) NOT NULL,
PRIMARY KEY (Student_ID)
);
CREATE TABLE PROFESSOR_INFO (
Professor_ID varchar(20) NOT NULL,
Professor_Name varchar(100) NOT NULL,
Professor_Email varchar(29) NOT NULL,
Warr_office varchar(8),
MIC_office varchar(8),
PRIMARY KEY (Professor_ID)
);
Prof info insert
INSERT INTO professor_info VALUES ("aksoy", "Ahmet Aksoy", "[email protected]", "WCM115", NULL);
INSERT INTO professor_info VALUES ("hchen", "Hang Chen", "[email protected]", "WCM205C", NULL);
INSERT INTO professor_info VALUES ("copus", "Belinda Copus", "[email protected]", "WCM206C", NULL);
INSERT INTO professor_info VALUES ("grebe", "Mark Grebe", "[email protected]", "WCM213", NULL);
INSERT INTO professor_info VALUES ("dding", "Dabin Ding", "[email protected]", "WCM211", NULL);
INSERT INTO professor_info VALUES ("haque", "Taiabul Haque", "[email protected]", "WCM116X", NULL);
INSERT INTO professor_info VALUES ("thorn", "Trang Horn", "[email protected]", "WCM205D", NULL);
INSERT INTO professor_info VALUES ("tkang", "Taeghyun Kang", "[email protected]", "WCM219", NULL);
INSERT INTO professor_info VALUES ("lui", "Yui Man Lui", "[email protected]", "WCM119", NULL);
INSERT INTO professor_info VALUES ("park", "Hyungbae Park", "[email protected]", "WCM223", NULL);
INSERT INTO professor_info VALUES ("ipark", "Ikhyun Park", "[email protected]", "WCM221", NULL);
INSERT INTO professor_info VALUES ("arawashdeh", "Ahmad Rawashdeh", "[email protected]", NULL, "MICD162");
INSERT INTO professor_info VALUES ("rawashdeh", "Mohammad Rawashdeh", "[email protected]", NULL, "MICD158");
INSERT INTO professor_info VALUES ("reza", "Farhadur Reza", "[email protected]", NULL, "MICD160");
INSERT INTO professor_info VALUES ("sshin", "Sunae Shin", "[email protected]", NULL, "MICD159");
INSERT INTO professor_info VALUES ("tian", "Songlin Tian", "[email protected]", "WCM215", NULL);
INSERT INTO professor_info VALUES ("jwang", "Jun Wang", "[email protected]", "WCM116L", NULL);
INSERT INTO professor_info VALUES ("yousef", "Mahmoud Yousef", "[email protected]", "WCM217", NULL);
INSERT INTO professor_info VALUES ("yue", "Xiaodong Yue", "[email protected]", "WCM222C", NULL);
INSERT INTO professor_info VALUES ("zzhou", "Zhiguo Zhou", "[email protected]", "WCM116F", NULL);
CREATE TABLE COURSE_LIST(
course_name varchar(255) NOT NULL,
course_code varchar(8) NOT NULL,
professor_ID varchar(20) NOT NULL,
FOREIGN KEY (professor_ID)
REFERENCES professor_info(professor_ID)
ON DELETE CASCADE
);
CREATE TABLE Available_times(
available_id int auto_increment,
location varchar(8) NOT NULL,
day varchar(9) NOT NULL,
start_time TIME NOT NULL,
end_time TIME NOT NULL,
date DATE NOT NULL,
available BOOLEAN NOT NULL,
professor_ID varchar(20) NOT NULL,
PRIMARY KEY(appointment_id),
FOREIGN KEY (professor_ID) REFERENCES professor_info(professor_ID)ON DELETE CASCADE,
CONSTRAINT mustStartOnTHIRTYMinuteBoundary CHECK (
EXTRACT(MINUTE FROM start_time) % 30 = 0
AND EXTRACT(SECOND FROM start_time) = 0
),
CONSTRAINT mustEndOnTHIRTYMinuteBoundary CHECK (
EXTRACT(MINUTE FROM end_time) % 30 = 0
AND EXTRACT(SECOND FROM end_time) = 0
),
CONSTRAINT cannotStartBefore0800 CHECK (
EXTRACT(HOUR FROM start_time) >= 8
),
CONSTRAINT cannotEndAfter1700 CHECK (
EXTRACT(HOUR FROM (start_time - INTERVAL 1 SECOND)) < 17
),
CONSTRAINT mustEndAfterStart CHECK (
end_time > start_time
)
);
INSERT INTO AVAILTIMES TABLE FOR PROFS
INSERT INTO Available_times VALUES (“THE LOCATION”, WEEKDAY('2020-02-07'),”09:30”, “10:00”, '2020-02-07', “true/false”, “prof id”);
Make switch() statement on JS end to display the days based on the WEEKDAY return value:
WEEKDAY(): 0 - Monday, 1-Tuesday, 2-Wednesday, …. 6-Sunday
CREATE TABLE APPOINTMENT (
Professor_Email varchar(20) NOT NULL,
Student_Email varchar(17) NOT NULL,
course_code varchar(6) NOT NULL,
purpose varchar(25) NOT NULL,
office varchar(8) NOT NULL,
start_time time NOT NULL,
end_time time NOT NULL,
appointment_description varchar(255),
student_fname varchar(50) NOT NULL,
student_lname varchar(50) NOT NULL,
sent bool NOT NULL,
appointment_date date NOT NULL,
appointment_id int auto_increment,
PRIMARY KEY(appointment_id)
);