first MVP

This commit is contained in:
Maxime Van Hees
2025-11-14 21:07:10 +01:00
parent 31327c9969
commit 4d024a39f4
26 changed files with 2729 additions and 64 deletions

View File

@@ -0,0 +1,14 @@
-- Enforce undirected connection uniqueness and prevent self-edges
-- Prevent self-edge (A == B)
ALTER TABLE "Connection"
ADD CONSTRAINT "Connection_no_self_edge"
CHECK ("personAId" <> "personBId");
-- Unique undirected pair using functional index on LEAST/GREATEST
-- Ensures only one edge exists for a given unordered pair {A,B}
CREATE UNIQUE INDEX IF NOT EXISTS "Connection_undirected_pair_unique"
ON "Connection" (
(LEAST("personAId","personBId")),
(GREATEST("personAId","personBId"))
);