-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQLQuery1 (1).sql
101 lines (87 loc) · 2.5 KB
/
SQLQuery1 (1).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
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
--create database day3
use day3
create table Course
(
CourseKey nchar(10) not null,
CourseName nvarchar(50) not null,
CourseDescription nvarchar(200),
PRIMARY KEY (CourseKey)
)
create table Tutor
(
tutorID nchar(10) primary key,
lastname nvarchar(50) not null,
firstname nvarchar(50),
tutorPhone nchar(10) not null,
email nvarchar(50),
hireDate Date not null,
tStatus nchar(10) not null,
)
drop table if exists TutorCourse
create table TutorCourse
(
TutorKey nchar(10),
CourseKey nchar(10),
primary key (TutorKey, CourseKey),
FOREIGN KEY (TutorKey) REFERENCES Tutor (tutorID),
FOREIGN KEY (CourseKey) REFERENCES Course (CourseKey),
)
create table Ethnicity
(
EthnicKey nchar(10) primary key,
EthnicDescription nvarchar(50)
)
create table Student
(
ID nchar(10) primary key,
lastname nvarchar(50) not null,
firstname nvarchar(50),
email nvarchar(100),
phone nvarchar(10),
gender nchar(1),
age int,
citizen bit,
worker_retraining bit,
EthKey nchar(10),
FOREIGN KEY (EthKey) REFERENCES Ethnicity (EthnicKey)
)
create table studentcourse
(
studentid nchar(10),
courseid nchar(10),
student_course_quarter nchar(10),
primary key (studentid, courseid, student_course_quarter),
fOREIGN KEY (studentid) REFERENCES Student (ID),
fOREIGN KEY (courseid) REFERENCES Course (CourseKey)
)
drop table if exists sessionTable
create table sessionTable
(
sDate Date,
sTime Time,
TutorKey nchar(10),
CourseKey nchar(10),
StudentKey nchar(10),
sStatus nchar(10),
sMaterialCovered nvarchar(255),
primary key (sDate, sTime, TutorKey, CourseKey),
FOREIGN KEY (TutorKey, CourseKey) REFERENCES TutorCourse (TutorKey, CourseKey),
fOREIGN KEY (StudentKey) REFERENCES Student (ID),
)
create table request
(
requestKey nchar(10) primary key,
requestDate Date,
courseKey nchar(10),
requestStatus nchar(10),
studentKey nchar(10),
FOREIGN KEY (courseKey) REFERENCES Course (CourseKey),
FOREIGN KEY (StudentKey) REFERENCES Student (ID)
)
create table requestNote
(
id DateTime primary key,
RequestKey nchar(10),
NoteText nvarchar(Max),
FOREIGN KEY (RequestKey) REFERENCES request (requestKey)
)