-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
81 lines (64 loc) · 2 KB
/
schema.sql
File metadata and controls
81 lines (64 loc) · 2 KB
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
CREATE TABLE "student" (
"student_id" SERIAL PRIMARY KEY,
"section_id" int,
"USN" varchar(10),
"Name" varchar(60),
"password" varchar,
"email" varchar(64),
"branch" varchar
);
CREATE TABLE "teachers" (
"teacher_id" SERIAL PRIMARY KEY,
"name" varchar(60),
"password" varchar,
"email" varchar(64),
"department" varchar
);
CREATE TABLE "sections" (
"section_id" SERIAL PRIMARY KEY,
"section" varchar,
"semester" int
);
CREATE TABLE "courses" (
"course_id" SERIAL PRIMARY KEY,
"department" varchar,
"course_code" varchar(10)
);
CREATE TABLE "classes" (
"section_id" int,
"course_id" int,
"link" varchar,
"day" varchar(10),
"time" time,
"class_id" SERIAL PRIMARY KEY,
"teacher_id" integer
);
CREATE TABLE "grades" (
"student_id" int,
"course_id" int,
"semester" int,
"CIE_1" int,
"CIE_2" int,
"CIE_3" int,
"AAT" int,
"SEE" int,
"section_id" int
);
CREATE TABLE "Attendance" (
"student_id" int,
"course_id" int,
"missed" int,
"total" int,
"section_id" int
);
ALTER TABLE "classes" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("section_id");
ALTER TABLE "classes" ADD FOREIGN KEY ("course_id") REFERENCES "courses" ("course_id");
ALTER TABLE "classes" ADD FOREIGN KEY ("teacher_id") REFERENCES "teachers" ("teacher_id");
ALTER TABLE "grades" ADD FOREIGN KEY ("student_id") REFERENCES "student" ("student_id");
ALTER TABLE "grades" ADD FOREIGN KEY ("course_id") REFERENCES "courses" ("course_id");
ALTER TABLE "grades" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("section_id");
ALTER TABLE "Attendance" ADD FOREIGN KEY ("student_id") REFERENCES "student" ("student_id");
ALTER TABLE "Attendance" ADD FOREIGN KEY ("course_id") REFERENCES "courses" ("course_id");
ALTER TABLE "Attendance" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("section_id");
ALTER TABLE "student" ADD FOREIGN KEY ("section_id") REFERENCES "sections" ("section_id");
ALTER TABLE "teachers" ADD FOREIGN KEY ("department") REFERENCES "courses" ("department");