-
Notifications
You must be signed in to change notification settings - Fork 0
/
CREATE TABLE
54 lines (46 loc) · 1.38 KB
/
CREATE TABLE
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
DROP TABLE IF EXISTS dbo.SECTION;
DROP TABLE IF EXISTS dbo.COURSES;
DROP TABLE IF EXISTS dbo.STUDENTS;
DROP TABLE IF EXISTS dbo.INSTRUCTORS;
DROP TABLE IF EXISTS dbo.DEPARTMENTS;
DROP TABLE IF EXISTS dbo.CLASSROOMS;
CREATE TABLE CLASSROOMS (
dept_building INT NOT NULL PRIMARY KEY,
dept_room_number varchar(50),
dept_room_capacity INT NOT NULL,
);
CREATE TABLE DEPARTMENTS (
dept_name INT NOT NULL PRIMARY KEY,
dept_building INT NOT NULL,
dept_budget INT,
FOREIGN KEY(dept_building) REFERENCES dbo.CLASSROOMS(dept_building)
);
CREATE TABLE INSTRUCTORS (
dept_name INT NOT NULL,
instructor_id INT NOT NULL,
instructor_name varchar(50),
instructor_salary INT,
FOREIGN KEY(dept_name) REFERENCES dbo.DEPARTMENTS(dept_name)
);
CREATE TABLE STUDENTS (
dept_name INT NOT NULL,
student_id INT NOT NULL,
student_name varchar(50),
student_total_credit INT,
FOREIGN KEY(dept_name) REFERENCES dbo.DEPARTMENTS(dept_name)
);
CREATE TABLE COURSES (
dept_name INT NOT NULL,
Course_id INT NOT NULL PRIMARY KEY,
Course_title varchar(50),
Course_credits INT,
Course_prerequisites varchar(50),
FOREIGN KEY(dept_name) REFERENCES dbo.DEPARTMENTS(dept_name)
);
CREATE TABLE SECTION (
Course_id INT NOT NULL,
Section_id INT NOT NULL,
Section_year INT,
Section_semester varchar(50),
FOREIGN KEY(Course_id) REFERENCES dbo.COURSES(Course_id)
);