-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMS_Schema.sql
executable file
·67 lines (58 loc) · 2.07 KB
/
CMS_Schema.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
drop database if exists college_mangement_system;
create database college_mangement_system;
use college_mangement_system;
drop table if exists Department;
create table Department (
ID int not null,
Name varchar(30) not null,
primary key Pk_Department (ID)
);
drop table if exists Course;
create table Course (
ID int not null,
Name varchar(50) not null,
DeptID int not null,
primary key Pk_Course (ID),
foreign key Fk_Course_Department (DeptID) references Department(ID)
);
drop table if exists Faculty;
create table Faculty (
ID int not null,
FirstName varchar(30) not null,
LastName varchar(50) not null,
DeptID int not null,
primary key Pk_Faculty (ID),
foreign key Fk_Faculty_Department (DeptID) references Department(ID)
);
drop table if exists FacultyCourse;
create table FacultyCourse (
FacultyID int not null,
CourseID int not null,
primary key Pk_FacultyCourse (FacultyID, CourseID),
foreign key Fk_FacultyCourse_Faculty (FacultyID) references Faculty(ID),
foreign key Fk_FacultyCourse_Course (CourseID) references Course(ID)
);
drop table if exists Student;
create table Student (
ID int not null,
FirstName varchar(30) not null,
LastName varchar(50) not null,
Street varchar(50) not null,
StreetDetail varchar(30) default null,
City varchar(30) not null,
State varchar(30) not null,
PostalCode char(5) not null,
MajorID int not null,
primary key Pk_Student (ID),
foreign key Fk_Student_Department (MajorID) references Department(ID)
);
drop table if exists StudentCourse;
create table StudentCourse (
CourseID int not null,
StudentID int not null,
Progress int null,
StartDate date not null,
primary key Pk_StudentCourse (CourseID, StudentID),
foreign key Fk_StudentCourse_Course (CourseID) references Course(ID),
foreign key Fk_StudentCourse_Student (StudentID) references Student(ID)
);