Skip to content

Commit 411f8bb

Browse files
committed
disallow that structures or properties are related to themselves
1 parent 6213077 commit 411f8bb

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

databases/catdat/schema/001_structures.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ CREATE TABLE related_structures (
2727
structure_id TEXT NOT NULL,
2828
related_structure_id TEXT NOT NULL,
2929
type TEXT NOT NULL,
30+
CHECK (structure_id != related_structure_id),
3031
PRIMARY KEY (structure_id, related_structure_id),
3132
FOREIGN KEY (structure_id, type) REFERENCES structures (id, type) ON DELETE CASCADE,
3233
FOREIGN KEY (related_structure_id, type) REFERENCES structures (id, type) ON DELETE CASCADE

databases/catdat/schema/002_properties.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CREATE TABLE related_properties (
2424
property_id TEXT NOT NULL,
2525
related_property_id TEXT NOT NULL,
2626
type TEXT NOT NULL,
27+
CHECK (property_id != related_property_id),
2728
PRIMARY KEY (property_id, related_property_id),
2829
FOREIGN KEY (property_id, type)
2930
REFERENCES properties (id, type) ON DELETE CASCADE,

0 commit comments

Comments
 (0)