-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tableUNIT2.sql
103 lines (94 loc) · 2.71 KB
/
create_tableUNIT2.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
102
103
CREATE TABLE Person
(
personID INT NOT NULL,
firstName VARCHAR2(20) NOT NULL,
lastName VARCHAR2(20) NOT NULL,
birthDate DATE NOT NULL,
email VARCHAR2(20) NOT NULL,
phoneNumber INT NOT NULL,
address VARCHAR2(30) NOT NULL,
PRIMARY KEY (personID)
);
CREATE TABLE Student
(
GPA FLOAT NOT NULL,
studingYear INT NOT NULL,
personID INT NOT NULL,
PRIMARY KEY (personID),
FOREIGN KEY (PersonID) REFERENCES Person(PersonID)
);
CREATE TABLE Course
(
courseID INT NOT NULL,
courseName VARCHAR2(40) NOT NULL,
credit FLOAT NOT NULL,
PRIMARY KEY (courseID)
);
CREATE TABLE CourseInSemester
(
semester VARCHAR2(10) NOT NULL,
currentYear INT NOT NULL,
groupNumber INT NOT NULL,
courseID INT NOT NULL,
PRIMARY KEY (semester,currentYear, courseID),
FOREIGN KEY (courseID) REFERENCES Course(courseID)
);
CREATE TABLE Lecturer
(
seniority INT NOT NULL,
salary FLOAT NOT NULL,
personID INT NOT NULL,
PRIMARY KEY (personID),
FOREIGN KEY (PersonID) REFERENCES Person(PersonID)
);
CREATE TABLE Question
(
questionId INT NOT NULL,
score_ FLOAT NOT NULL,
typeOfQuestion VARCHAR2(20) NOT NULL,
questionbody VARCHAR2(30) NOT NULL,
PRIMARY KEY (questionId)
);
CREATE TABLE StudentTakeCourse
(
examGrade FLOAT NOT NULL,
assignmentsGrade FLOAT NOT NULL,
personID INT NOT NULL,
semester VARCHAR2(10) NOT NULL,
currentYear INT NOT NULL,
courseID INT NOT NULL,
PRIMARY KEY (personID, semester, currentYear, courseID),
FOREIGN KEY (personID) REFERENCES Student(personID),
FOREIGN KEY (semester,currentYear, courseID) REFERENCES CourseInSemester(semester,currentYear, courseID)
);
CREATE TABLE LecturerTeachCourse
(
semester VARCHAR2(10) NOT NULL,
currentYear INT NOT NULL,
courseID INT NOT NULL,
personID INT NOT NULL,
PRIMARY KEY (semester, currentYear, courseID, personID),
FOREIGN KEY (semester,currentYear, courseID) REFERENCES CourseInSemester(Semester, currentYear, courseID),
FOREIGN KEY (personID) REFERENCES Lecturer(personID)
);
CREATE TABLE CourseQuestions
(
courseID INT NOT NULL,
questionId INT NOT NULL,
PRIMARY KEY (CourseID, questionId),
FOREIGN KEY (CourseID) REFERENCES Course(CourseID),
FOREIGN KEY (questionId) REFERENCES Question(questionId)
);
CREATE TABLE Exam
(
examName VARCHAR2(30) NOT NULL,
typeOfExam VARCHAR2(20) NOT NULL,
Moed VARCHAR2(10) NOT NULL,
ExamDate DATE NOT NULL,
timeOfExam INT NOT NULL,
semester VARCHAR2(10) NOT NULL,
currentYear INT NOT NULL,
courseID INT NOT NULL,
PRIMARY KEY (semester, currentYear, courseID,moed),
FOREIGN KEY (semester, currentYear, courseID) REFERENCES CourseInSemester(semester,currentYear, courseID)
);