Skip to content

Commit

Permalink
Merge pull request #24 from ctc-uci/6-create-class-enrollments-and-cl…
Browse files Browse the repository at this point in the history
…asses-taught-tables

added class_enrolled and class_taught sql schema
  • Loading branch information
h0ethan04 authored Dec 6, 2024
2 parents 23e53bb + cc52868 commit b67a977
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/db/schema/class_enrollments.sql
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
)
17 changes: 17 additions & 0 deletions server/db/schema/classes_taught.sql
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
)

0 comments on commit b67a977

Please sign in to comment.