generated from ctc-uci/npo-template-merged
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from ctc-uci/6-create-class-enrollments-and-cl…
…asses-taught-tables added class_enrolled and class_taught sql schema
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE TABLE IF NOT EXISTS class_enrollments ( | ||
id SERIAL, | ||
student_id INTEGER NOT NULL, | ||
class_id INTEGER NOT NULL, | ||
attendance DATE NOT NULL, | ||
|
||
CONSTRAINT Pk_class_enrollments | ||
PRIMARY KEY(student_id, class_id, id), | ||
|
||
CONSTRAINT fk_student | ||
FOREIGN KEY(student_id) | ||
REFERENCES student(id) | ||
ON DELETE CASCADE, | ||
|
||
CONSTRAINT fk_class | ||
FOREIGN KEY(class_id) | ||
REFERENCES classes(id) | ||
ON DELETE CASCADE | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE TABLE IF NOT EXISTS classes_taught ( | ||
class_id INTEGER NOT NULL, | ||
teacher_id INTEGER NOT NULL, | ||
|
||
CONSTRAINT Pk_classes_taught | ||
PRIMARY KEY(class_id, teacher_id), | ||
|
||
CONSTRAINT fk_class | ||
FOREIGN KEY(class_id) | ||
REFERENCES classes(id) | ||
ON DELETE CASCADE, | ||
|
||
CONSTRAINT fk_teacher | ||
FOREIGN KEY(teacher_id) | ||
REFERENCES teacher(id) | ||
ON DELETE CASCADE | ||
) |