Make constraints directional and add mismatch detection

This commit is contained in:
Ian Gulliver
2026-02-15 19:26:38 -08:00
parent c92f7d7d60
commit d74892e895
5 changed files with 75 additions and 34 deletions

View File

@@ -43,6 +43,6 @@ CREATE TABLE IF NOT EXISTS roommate_constraints (
student_b_id BIGINT NOT NULL REFERENCES students(id) ON DELETE CASCADE,
kind constraint_kind NOT NULL,
level constraint_level NOT NULL,
CHECK(student_a_id < student_b_id),
CHECK(student_a_id != student_b_id),
UNIQUE(student_a_id, student_b_id, level)
);