-
Notifications
You must be signed in to change notification settings - Fork 0
/
Commands.sql
115 lines (112 loc) · 3.17 KB
/
Commands.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
104
105
106
107
108
109
110
111
112
113
114
CREATE TABLE INSTRUCTOR (
InstructorID VARCHAR(100) PRIMARY KEY,
FName VARCHAR(100),
LName VARCHAR(100),
StartDate DATE,
Degree VARCHAR(100),
`Rank` VARCHAR(100),
Type VARCHAR(100)
);/* Rank is a key word used the `` to force sql intellisense to recognize it as a column name. */
CREATE TABLE TT (
InstructorID VARCHAR(100) PRIMARY KEY,
NoOfPhDStudents INT,
FOREIGN KEY (InstructorID)
REFERENCES INSTRUCTOR (InstructorID)
);
CREATE TABLE PHDSTUDENT (
StudentID VARCHAR(100) PRIMARY KEY,
FName VARCHAR(100),
LName VARCHAR(100),
StSem VARCHAR(100),
StYear VARCHAR(100),
Supervisor VARCHAR(100)
);
CREATE TABLE GTA (
SectionID VARCHAR(100),
MonthlyPay DOUBLE,
StudentID VARCHAR(100) PRIMARY KEY,
FOREIGN KEY (StudentID)
REFERENCES PHDSTUDENT (StudentID)
);
CREATE TABLE GRA (
StudentID VARCHAR(100) PRIMARY KEY,
Funding VARCHAR(100),
MonthlyPay DOUBLE,
FOREIGN KEY (StudentID)
REFERENCES PHDSTUDENT (StudentID)
);
CREATE TABLE SELFSUPPORT (
StudentID VARCHAR(100) PRIMARY KEY,
FOREIGN KEY (StudentID)
REFERENCES PHDSTUDENT (StudentID)
);
CREATE TABLE SCHOLARSHIPSUPPORT (
StudentID VARCHAR(100) PRIMARY KEY,
Type VARCHAR(100),
Source VARCHAR(100),
FOREIGN KEY (StudentID)
REFERENCES PHDSTUDENT (StudentID)
);
CREATE TABLE COURSE (
CourseID VARCHAR(100) PRIMARY KEY,
CName VARCHAR(100)
);
CREATE TABLE SECTION (
SectionID VARCHAR(100) PRIMARY KEY,
CourseID VARCHAR(100),
FOREIGN KEY (CourseID)
REFERENCES COURSE (CourseID)
);
alter table GTA add constraint foreign key(SectionID) references SECTION(SectionID);/* Adding the constraint for GTA to Section now that the SECTION Table has been made by altering the GTA table */
CREATE TABLE COURSESTAUGHT (
CourseID VARCHAR(100),
InstructorID VARCHAR(100),
PRIMARY KEY (CourseID , InstructorID),
FOREIGN KEY (CourseID)
REFERENCES COURSE (CourseID),
FOREIGN KEY (InstructorID)
REFERENCES INSTRUCTOR (InstructorID)
);
CREATE TABLE MILESTONE (
MId VARCHAR(100) PRIMARY KEY,
MName VARCHAR(100)
);
CREATE TABLE MILESTONEPASSED (
StudentID VARCHAR(100),
MId VARCHAR(100),
PRIMARY KEY (StudentID , MId),
FOREIGN KEY (StudentID)
REFERENCES PHDSTUDENT (StudentID),
FOREIGN KEY (MId)
REFERENCES MILESTONE (MId),
PassDate DATE
);
CREATE TABLE GRANTS (
AccountNo VARCHAR(100) PRIMARY KEY,
Type VARCHAR(100),
GrantTitle VARCHAR(100),
Source VARCHAR(100),
StDate DATE,
EndDate DATE,
StAmount DOUBLE,
CurrBalance DOUBLE
);
CREATE TABLE GRANTSASSOCIATED (
AccountNo VARCHAR(100),
InstructorID VARCHAR(100),
PRIMARY KEY (AccountNo , InstructorID),
PIType VARCHAR(100),
FOREIGN KEY (AccountNo)
REFERENCES GRANTS (AccountNo),
FOREIGN KEY (InstructorID)
REFERENCES INSTRUCTOR (InstructorID)
);
CREATE TABLE PHDCOMMITTEE (
StudentID VARCHAR(100),
InstructorID VARCHAR(100),
PRIMARY KEY (StudentID , InstructorID),
FOREIGN KEY (StudentID)
REFERENCES PHDSTUDENT (StudentID),
FOREIGN KEY (InstructorID)
REFERENCES INSTRUCTOR (InstructorID)
);