This repository was archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMS2_DataSample.sql
More file actions
373 lines (338 loc) · 14.6 KB
/
Copy pathMS2_DataSample.sql
File metadata and controls
373 lines (338 loc) · 14.6 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
-- Adding 10 records to the Course table
INSERT INTO Course(name, major, is_offered, credit_hours, semester) VALUES
( 'Mathematics 2', 'Science', 1, 3, 2),
( 'CSEN 2', 'Engineering', 1, 4, 2),
( 'Database 1', 'MET', 1, 3, 5),
( 'Physics', 'Science', 0, 4, 1),
( 'CSEN 4', 'Engineering', 1, 3, 4),
( 'Chemistry', 'Engineering', 1, 4, 1),
( 'CSEN 3', 'Engineering', 1, 3, 3),
( 'Computer Architecture', 'MET', 0, 3, 6),
( 'Computer Organization', 'Engineering', 1, 4, 4),
( 'Database2', 'MET', 1, 3, 6);
-- Adding 10 records to the Instructor table
INSERT INTO Instructor(name, email, faculty, office) VALUES
( 'Professor Smith', 'prof.smith@example.com', 'MET', 'Office A'),
( 'Professor Johnson', 'prof.johnson@example.com', 'MET', 'Office B'),
( 'Professor Brown', 'prof.brown@example.com', 'MET', 'Office C'),
( 'Professor White', 'prof.white@example.com', 'MET', 'Office D'),
( 'Professor Taylor', 'prof.taylor@example.com', 'Mechatronics', 'Office E'),
( 'Professor Black', 'prof.black@example.com', 'Mechatronics', 'Office F'),
( 'Professor Lee', 'prof.lee@example.com', 'Mechatronics', 'Office G'),
( 'Professor Miller', 'prof.miller@example.com', 'Mechatronics', 'Office H'),
( 'Professor Davis', 'prof.davis@example.com', 'IET', 'Office I'),
( 'Professor Moore', 'prof.moore@example.com', 'IET', 'Office J');
-- Adding 10 records to the Semester table
INSERT INTO Semester(semester_code, start_date, end_date) VALUES
('W23', '2023-10-01', '2024-01-31'),
('S23', '2023-03-01', '2023-06-30'),
('S23R1', '2023-07-01', '2023-07-31'),
('S23R2', '2023-08-01', '2023-08-31'),
('W24', '2024-10-01', '2025-01-31'),
('S24', '2024-03-01', '2024-06-30'),
('S24R1', '2024-07-01', '2024-07-31'),
('S24R2', '2024-08-01', '2024-08-31')
-- Adding 10 records to the Advisor table
INSERT INTO Advisor(name, email, office, password) VALUES
( 'Dr. Anderson', 'anderson@example.com', 'Office A', 'password1'),
( 'Prof. Baker', 'baker@example.com', 'Office B', 'password2'),
( 'Dr. Carter', 'carter@example.com', 'Office C', 'password3'),
( 'Prof. Davis', 'davis@example.com', 'Office D', 'password4'),
( 'Dr. Evans', 'evans@example.com', 'Office E', 'password5'),
( 'Prof. Foster', 'foster@example.com', 'Office F', 'password6'),
( 'Dr. Green', 'green@example.com', 'Office G', 'password7'),
( 'Prof. Harris', 'harris@example.com', 'Office H', 'password8'),
( 'Dr. Irving', 'irving@example.com', 'Office I', 'password9'),
( 'Prof. Johnson', 'johnson@example.com', 'Office J', 'password10');
-- Adding 10 records to the Student table
INSERT INTO Student (f_name, l_name, GPA, faculty, email, major, password, financial_status, semester, acquired_hours, assigned_hours, advisor_id) VALUES
( 'John', 'Doe', 3.5, 'Engineering', 'john.doe@example.com', 'CS', 'password123', 1, 1, 90, 30, 1),
( 'Jane', 'Smith', 3.8, 'Engineering', 'jane.smith@example.com', 'CS', 'password456', 1, 2, 85, 34, 2),
( 'Mike', 'Johnson', 3.2, 'Engineering', 'mike.johnson@example.com', 'CS', 'password789', 1, 3, 75, 34, 3),
( 'Emily', 'White', 3.9, 'Engineering', 'emily.white@example.com', 'CS', 'passwordabc', 0, 4, 95, 34, 4),
( 'David', 'Lee', 3.4, 'Engineering', 'david.lee@example.com', 'IET', 'passworddef', 1, 5, 80, 34, 5),
( 'Grace', 'Brown', 3.7, 'Engineering', 'grace.brown@example.com', 'IET', 'passwordghi', 0, 6, 88, 34, 6),
( 'Robert', 'Miller', 3.1, 'Engineerings', 'robert.miller@example.com', 'IET', 'passwordjkl', 1, 7, 78, 34, 7),
( 'Sophie', 'Clark', 3.6, 'Engineering', 'sophie.clark@example.com', 'Mechatronics', 'passwordmno', 1, 8, 92, 34, 8),
( 'Daniel', 'Wilson', 3.3, 'Engineering', 'daniel.wilson@example.com', 'DMET', 'passwordpqr', 1, 9, 87, 34, 9),
( 'Olivia', 'Anderson', 3.7, 'Engineeringe', 'olivia.anderson@example.com', 'Mechatronics', 'passwordstu', 0, 10, 89, 34, 10);
-- Adding 10 records to the Student_Phone table
INSERT INTO Student_Phone(student_id, phone_number) VALUES
(4, '456-789-0123'),
(5, '567-890-1234'),
(6, '678-901-2345'),
(7, '789-012-3456'),
(8, '890-123-4567'),
(9, '901-234-5678'),
(10, '012-345-6789');
-- Adding 10 records to the PreqCourse_course table
INSERT INTO PreqCourse_course(prerequisite_course_id, course_id) VALUES
(2, 7),
(3, 10),
(2, 4),
(5, 6),
(4, 7),
(6, 8),
(7, 9),
(9, 10),
(9, 1),
(10, 3);
-- Adding 10 records to the Instructor_Course table
INSERT INTO Instructor_Course (instructor_id, course_id) VALUES
(1, 1),
(2, 2),
(3, 3),
(4, 4),
(5, 5),
(6, 6),
(7, 7),
(8, 8),
(9, 9),
(10, 10);
-- Adding 10 records to the Student_Instructor_Course_Take table
INSERT INTO Student_Instructor_Course_Take (student_id, course_id, instructor_id, semester_code,exam_type, grade) VALUES
(1, 1, 1, 'W23', 'Normal', 'A'),
(2, 2, 2, 'S23', 'First_makeup', 'B'),
(3, 3, 3, 'S23R1', 'Second_makeup', 'C'),
(4, 4, 4, 'S23R2', 'Normal', 'B+'),
(5, 5, 5, 'W23', 'Normal', 'A-'),
(6, 6, 6, 'W24', 'First_makeup', 'B'),
(7, 7, 7, 'S24', 'Second_makeup', 'C+'),
(8, 8, 8, 'S24R1', 'Normal', 'A+'),
(9, 9, 9, 'S24R2', 'Normal', 'FF'),
(10, 10, 10, 'S24', 'First_makeup', 'B-');
-- Adding 10 records to the Course_Semester table
INSERT INTO Course_Semester (course_id, semester_code) VALUES
(1, 'W23'),
(2, 'S23'),
(3, 'S23R1'),
(4, 'S23R2'),
(5, 'W23'),
(6, 'W24'),
(7, 'S24'),
(8, 'S24R1'),
(9, 'S24R2'),
(10, 'S24');
-- Adding 10 records to the Slot table
INSERT INTO Slot (day, time, location, course_id, instructor_id) VALUES
( 'Monday', 'First', 'Room A', 1, 1),
( 'Tuesday', 'First', 'Room B', 2, 2),
( 'Wednesday', 'Third', 'Room C', 3, 3),
( 'Thursday', 'Fifth', 'Room D', 4, 4),
( 'Saturday', 'Second', 'Room E', 5, 5),
( 'Monday', 'Fourth', 'Room F', 6, 6),
( 'Tuesday', 'Second', 'Room G', 7, 7),
( 'Wednesday', 'Fifth', 'Room H', 8, 8),
( 'Thursday', 'First', 'Room I', 9, 9),
( 'Sunday', 'Fourth', 'Room J', 10, 10);
-- Adding 10 records to the Graduation_Plan table
INSERT INTO Graduation_Plan (semester_code, semester_credit_hours, expected_grad_date, student_id, advisor_id) VALUES
( 'W23', 90, '2024-01-31' , 1, 1),
( 'S23', 85, '2025-01-31' , 2, 2),
( 'S23R1', 75, '2025-06-30' , 3, 3),
( 'S23R2', 95, '2024-06-30' , 4, 4),
( 'W23', 80, '2026-01-31' , 5, 5),
( 'W24', 88, '2024-06-30' , 6, 6),
( 'S24', 78, '2024-06-30' , 7, 7),
( 'S24R1', 92, '2025-01-31' , 8, 8),
( 'S24R2', 87, '2024-06-30' , 9, 9),
( 'S24', 89, '2025-01-31' , 10, 10);
-- Adding 10 records to the GradPlan_Course table
INSERT INTO GradPlan_Course(plan_id, semester_code, course_id) VALUES
(1, 'W23', 1),
(2, 'S23', 2),
(3, 'S23R1', 3),
(4, 'S23R2', 4),
(5, 'W23', 5),
(6, 'W24', 6),
(7, 'S24', 7),
(8, 'S24R1', 8),
(9, 'S24R2', 9),
(10, 'S24', 10);
-- Adding 10 records to the Request table
INSERT INTO Request (type, comment, status, credit_hours, course_id, student_id, advisor_id) VALUES
( 'course', 'Request for additional course', 'pending', null, 1, 1, 2),
( 'course', 'Need to change course', 'approved', null, 2, 2, 2),
( 'credit_hours', 'Request for extra credit hours', 'pending', 3, null, 3, 3),
( 'credit_hours', 'Request for reduced credit hours', 'approved', 1, null, 4, 5),
( 'course', 'Request for special course', 'rejected', null, 5, 5, 5),
( 'credit_hours', 'Request for extra credit hours', 'pending', 4, null, 6, 7),
( 'course', 'Request for course withdrawal', 'approved', null, 7, 7, 7),
( 'course', 'Request for course addition', 'rejected', null, 8, 8, 8),
( 'credit_hours', 'Request for reduced credit hours', 'approved', 2, null, 9, 8),
( 'course', 'Request for course substitution', 'pending', null, 10, 10, 10);
-- Adding 10 records to the MakeUp_Exam table
INSERT INTO MakeUp_Exam (date, type, course_id) VALUES
('2023-02-10', 'First MakeUp', 1),
('2023-02-15', 'First MakeUp', 2),
('2023-02-05', 'First MakeUp', 3),
('2023-02-25', 'First MakeUp', 4),
('2023-02-05', 'First MakeUp', 5),
('2024-09-10', 'Second MakeUp', 6),
('2024-09-20', 'Second MakeUp', 7),
('2024-09-05', 'Second MakeUp', 8),
('2024-09-10', 'Second MakeUp', 9),
( '2024-09-15', 'Second MakeUp', 10);
-- Adding 10 records to the Exam_Student table
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (1, 1, 1);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (1, 2, 2);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (1, 3, 3);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (2, 2, 4);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (2, 3, 5);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (2, 4, 6);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (3, 3, 7);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (3, 4, 8);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (3, 5, 9);
INSERT INTO Exam_Student(exam_id, student_id,course_id) VALUES (4, 4, 10);
-- Adding 10 records to the Payment table
INSERT INTO Payment (amount, start_date,n_installments, status, fund_percentage, student_id, semester_code, deadline) VALUES
( 500, '2023-11-22', 1, 'notPaid', 50.00, 1, 'W23', '2023-12-22'),
( 700, '2023-11-23', 1, 'notPaid', 60.00, 2, 'S23', '2023-12-23'),
( 600, '2023-11-24', 4, 'notPaid', 40.00, 3, 'S23R1', '2024-03-24'),
( 800, '2023-11-25', 1, 'notPaid', 70.00, 4, 'S23R2', '2023-12-25'),
( 550, '2023-11-26', 5, 'notPaid', 45.00, 5, 'W23', '2024-04-26'),
( 900, '2023-11-27', 1, 'notPaid', 80.00, 6, 'W24', '2023-12-27'),
( 750, '2023-10-28', 2, 'Paid', 65.00, 7, 'S24', '2023-12-28'),
( 620, '2023-08-29', 4, 'Paid', 55.00, 8, 'S24R1', '2023-12-29'),
( 720, '2023-11-30', 2, 'notPaid', 75.00, 9, 'S24R2', '2024-01-30'),
( 580, '2023-11-30', 1, 'Paid', 47.00, 10, 'S24', '2023-12-31');
-- Adding 10 records to the Installment table
INSERT INTO Installment (payment_id, start_date, amount, status, deadline) VALUES
(1, '2023-11-22', 50, 'notPaid','2023-12-22'),
(2, '2023-11-23', 70, 'notPaid','2023-12-23'),
(3, '2023-12-24', 60, 'notPaid','2024-01-24'),
( 4,'2023-11-25', 80, 'notPaid','2023-12-25'),
(5, '2024-2-26', 55, 'notPaid','2024-3-26'),
( 6,'2023-11-27', 90, 'notPaid','2023-12-06'),
(7, '2023-10-28', 75, 'Paid','2023-11-28'),
( 7,'2023-11-28', 62, 'Paid','2023-12-28'),
( 9,'2023-12-30', 72, 'notPaid','2024-01-30'),
( 10,'2023-11-30', 58, 'Paid','2023-12-30');
--create the tables:
exec CreateAllTables
--test all the views
select * from dbo.Advisors_Graduation_Plan
select * from dbo.Courses_Slots_Instructor
select * from dbo.Courses_MakeupExams
select * from dbo.Instructors_AssignedCourses
select * from dbo.Semster_offered_Courses
select * from dbo.Students_Courses_transcript
select * from dbo.view_Course_prerequisites
select * from dbo.view_Students
select * from Student
select * from dbo.Student_Payment
--select * from all tables
select * from Advisor
select * from Course
select * from Course_Semester
select * from Exam_Student
select * from GradPlan_Course
select * from Graduation_Plan
select * from Instructor
select * from Instructor_Course
select * from Installment
select * from MakeUp_Exam
select * from Payment
select * from PreqCourse_course
select * from Request
select * from Semester
select * from Slot
select * from Student
select * from Student_Instructor_Course_Take
select * from Student_Phone
select * from Student_Payment
---drop all views
drop view dbo.Advisors_Graduation_Plan
drop view dbo.Courses_Slots_Instructor
drop view dbo.Courses_MakeupExams
drop view dbo.Instructors_AssignedCourses
drop view dbo.Semster_offered_Courses
drop view dbo.Students_Courses_transcript
drop view dbo.view_Course_prerequisites
drop view dbo.view_Students
drop view dbo.Student_Payment
--test all the procdedure from A to OO
declare @A int
declare @C int
exec Procedures_StudentRegistration 'ahmed', 'mohamed', '123', 'eng', '', 'cs', 1, @A output
exec Procedures_StudentRegistration 'shirley', 'mohamed', '123', 'eng', '', 'cs', 1, @C output
print @A
print @C
select * from Student
declare @B int
exec Procedures_AdminRegistration 'ahmed', '123', '', '', @B output
print @B
select * from Advisor
exec Procedures_AdminListStudents
exec Procedures_AdminListAdvisors
exec AdminListStudentsWithAdvisors
exec AdminAddingSemester '2020-01-01', '2020-01-01', S19
select * from Semester
exec Procedures_AdminAddingCourse 'MET', 5, 3, 'cs', 1
select * from Course
exec Procedures_AdminLinkInstructor 1, 1, 1
select * from Instructor_Course
exec Procedures_AdminLinkStudent 1, 1, 1, '2020-01-01'
exec Procedures_AdminLinkStudentToAdvisor 1, 1
exec Procedures_AdminAddExam 'cs', '2020-01-01', 1
exec all_Pending_Requests
exec Procedures_AdvisorAddCourseGP 1, '2020-01-01', 'cs'
exec Procedures_AdvisorUpdateGP '2020-01-01', 1
exec Procedures_AdvisorDeleteFromGP 1, '2020-01-01', 1
exec FN_Advisors_Requests 1
exec Procedures_AdvisorApproveRejectCHRequest 1, '2020-01-01'
exec Procedures_AdvisorViewAssignedStudents 1, 'cs'
exec Procedures_AdvisorApproveRejectCourseRequest 1, '2020-01-01'
exec Procedures_AdvisorViewPendingRequests 1
exec FN_StudentLogin 1, '123'
exec Procedures_StudentaddMobile 1, '123'
exec FN_SemsterAvailableCourses '2020-01-01'
exec Procedures_StudentSendingCourseRequest 1, 1, 'cs', 'cs'
exec Procedures_StudentSendingCHRequest 1, 1, 'cs', 'cs'
exec FN_StudentViewGP 1
exec FN_StudentUpcoming_installment 1
exec FN_StudentViewSlot 1, 1
exec Procedures_StudentRegisterFirstMakeup 1, 1, '2020-01-01'
exec FN_StudentCheckSMEligiability 1, 1
exec Procedures_StudentRegisterSecondMakeup 1, 1, '2020-01-01'
exec Procedures_ViewRequiredCourses 1, '2020-01-01'
exec Procedures_ViewOptionalCourse 1, '2020-01-01'
exec Procedures_ViewMS 1
exec Procedures_ChooseInstructor 1, 1, 1, '2020-01-01'
GO
--drop all the procedure from A to OO
drop proc Procedures_StudentRegistration
drop proc Procedures_AdminListStudents
drop proc Procedures_AdminListAdvisors
drop proc AdminListStudentsWithAdvisors
drop proc Procedures_AdminAddingSemester
drop proc Procedures_AdminAddingCourse
drop proc Procedures_AdminLinkInstructor
drop proc Procedures_AdminLinkStudent
drop proc Procedures_AdminLinkStudentToAdvisor
drop proc Procedures_AdminAddExam
drop proc all_Pending_Requests
drop proc Procedures_AdvisorAddCourseGP
drop proc Procedures_AdvisorUpdateGP
drop proc Procedures_AdvisorDeleteFromGP
drop proc FN_Advisors_Requests
drop proc Procedures_AdvisorApproveRejectCHRequest
drop proc Procedures_AdvisorViewAssignedStudents
drop proc Procedures_AdvisorApproveRejectCourseRequest
drop proc Procedures_AdvisorViewPendingRequests
drop proc FN_StudentLogin
drop proc Procedures_StudentaddMobile
drop proc FN_SemsterAvailableCourses
drop proc Procedures_StudentSendingCourseRequest
drop proc Procedures_StudentSendingCHRequest
drop proc FN_StudentViewGP
drop proc FN_StudentUpcoming_installment
drop proc FN_StudentViewSlot
drop proc Procedures_StudentRegisterFirstMakeup
drop proc FN_StudentCheckSMEligiability
drop proc Procedures_StudentRegisterSecondMakeup
drop proc Procedures_ViewRequiredCourses
drop proc Procedures_ViewOptionalCourse
drop proc Procedures_ViewMS
drop proc Procedures_ChooseInstructor
GO