-
Notifications
You must be signed in to change notification settings - Fork 1
/
Creating Database Old.txt
64 lines (56 loc) · 1.79 KB
/
Creating Database Old.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
CREATE TABLE SCHOOL_T (
schoolTitle varchar(6) NOT NULL,
schoolName varchar(50) NOT NULL,
PRIMARY KEY (schoolTitle)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE DEPARTMENT_T(
deptCode varchar(3) NOT NULL,
deptName varchar(50) NOT NULL,
schoolTitle varchar(6) NOT NULL,
PRIMARY KEY (deptCode),
FOREIGN KEY (schoolTitle)
REFERENCES school_t(schoolTitle)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE FACULTY_T (
facultyID INTEGER() NOT NULL,
facultyName VARCHAR(50) NOT NULL,
deptCode VARCHAR(3) NOT NULL,
PRIMARY KEY (facultyID),
FOREIGN KEY (deptCode)
REFERENCES department_t(deptCode)
)ENGINE = INNODB DEFAULT CHARSET=utf8mb4;
CREATE TABLE COURSE_T (
courseID VARCHAR(7) NOT NULL,
courseName VARCHAR(50) NOT NULL,
creditHour INTEGER() NOT NULL,
deptcode VARCHAR(3) NOT NULL,
semester VARCHAR(6) NOT NULL,
year YEAR(4) NOT NULL,
PRIMARY KEY (courseID),
FOREIGN KEY (deptCode)
REFERENCES department_t(deptCode)
)ENGINE = INNODB DEFAULT CHARSET=utf8mb4;
CREATE TABLE CLASSROOM_T(
roomID VARCHAR(7) NOT NULL,
roomCapacity INTEGER NOT NULL,
PRIMARY KEY (roomID)
)ENGINE = INNODB DEFAULT CHARSET=utf8mb4;
CREATE TABLE SECTION_T (
courseID VARCHAR(7) NOT NULL,
sectionNo INTEGER() NOT NULL,
semester VARCHAR(6) NOT NULL,
year YEAR(4) NOT NULL,
roomID VARCHAR(7) NOT NULL,
capacity INTEGER() NOT NULL,
noOfEnrolledStudent INTEGER() NOT NULL,
facultyID INTEGER() NOT NULL,
startTime TIME,
endTime TIME,
day VARCHAR(4) NOT NULL,
blocked VARCHAR(4) NOT NULL,
PRIMARY KEY (courseID, sectionNo, semester, year),
FOREIGN KEY (facultyID)
REFERENCES faculty_t(facultyID),
FOREIGN KEY (roomID)
REFERENCES classroom_t(roomID)
)ENGINE = INNODB DEFAULT CHARSET=utf8mb4;