-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql
64 lines (54 loc) · 1.74 KB
/
create.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
CREATE TABLE Department (
DepartmentID INTEGER PRIMARY KEY AUTOINCREMENT,
Name TEXT NOT NULL,
Budget INTEGER NOT NULL,
Administrator TEXT NOT NULL,
StartDate DATE NOT NULL
);
CREATE TABLE Course (
CourseID INTEGER PRIMARY KEY AUTOINCREMENT,
Title TEXT NOT NULL,
Credits TEXT NOT NULL,
DepartmentID INTEGER NOT NULL,
FOREIGN KEY (DepartmentID) REFERENCES Department (DepartmentID)
);
CREATE TABLE OnlineCourse (
CourseID INTEGER NOT NULL PRIMARY KEY,
URL TEXT NOT NULL,
FOREIGN KEY (CourseID) REFERENCES Course (CourseID)
);
CREATE TABLE OnsiteCourse (
CourseID INTEGER NOT NULL PRIMARY KEY,
Location TEXT NOT NULL,
Days INTEGER NOT NULL,
Time TEXT NOT NULL,
FOREIGN KEY (CourseID) REFERENCES Course (CourseID)
);
CREATE TABLE Person (
PersonID INTEGER PRIMARY KEY AUTOINCREMENT,
LastName TEXT NOT NULL,
FirstName TEXT NOT NULL,
HireDate DATE NOT NULL,
EnrollmentDate DATE NOT NULL
);
CREATE TABLE StudentGrade (
EnrollmentID INTEGER PRIMARY KEY AUTOINCREMENT,
CourseID INTEGER NOT NULL,
StudentID INTEGER NOT NULL,
Grade TEXT NOT NULL,
FOREIGN KEY (CourseID) REFERENCES Course (CourseID),
FOREIGN KEY (StudentID) REFERENCES Person (PersonID)
);
CREATE TABLE CourseInstructor (
CourseID INTEGER NOT NULL,
PersonID INTEGER NOT NULL,
FOREIGN KEY (CourseID) REFERENCES Course (CourseID),
FOREIGN KEY (PersonID) REFERENCES Person (PersonID),
PRIMARY KEY (CourseID,PersonID)
);
CREATE TABLE OfficeAssignment (
InstructorID INTEGER NOT NULL PRIMARY KEY,
Location TEXT NOT NULL,
TimeStamp INTEGER NOT NULL,
FOREIGN KEY (InstructorID) REFERENCES Person (PersonID)
);