A little store-level constraining never hurt nobody.

This commit is contained in:
Elf M. Sternberg 2020-11-05 05:45:57 -08:00
parent 9337b98ad3
commit 4776541df4
1 changed files with 4 additions and 2 deletions

View File

@ -32,7 +32,8 @@ CREATE TABLE note_relationships (
kind TEXT NOT NULL,
-- If either note disappears, we want all the edges to disappear as well.
FOREIGN KEY (note_id) REFERENCES notes (id) ON DELETE CASCADE,
FOREIGN KEY (parent_id) REFERENCES notes (id) ON DELETE CASCADE
FOREIGN KEY (parent_id) REFERENCES notes (id) ON DELETE CASCADE,
CHECK (note_id <> parent_id)
);
-- This table represents the graph of data relating notes to kastens.
@ -43,6 +44,7 @@ CREATE TABLE note_kasten_relationships (
kind TEXT NOT NULL,
-- If either note disappears, we want all the edges to disappear as well.
FOREIGN KEY (note_id) REFERENCES notes (id) ON DELETE CASCADE,
FOREIGN KEY (kasten_id) REFERENCES notes (id) ON DELETE CASCADE
FOREIGN KEY (kasten_id) REFERENCES notes (id) ON DELETE CASCADE,
CHECK (note_id <> kasten_id)
);