-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path011_functor-properties-tables.sql
More file actions
22 lines (21 loc) · 1.02 KB
/
011_functor-properties-tables.sql
File metadata and controls
22 lines (21 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CREATE TABLE functor_properties (
id TEXT PRIMARY KEY,
relation TEXT NOT NULL,
description TEXT NOT NULL CHECK (length(description) > 0),
nlab_link TEXT CHECK (nlab_link IS NULL OR nlab_link like 'https://%'),
invariant_under_equivalences INTEGER NOT NULL DEFAULT TRUE,
dual_property_id TEXT,
FOREIGN KEY (relation) REFERENCES relations (relation) ON DELETE RESTRICT,
FOREIGN KEY (dual_property_id) REFERENCES functor_properties (id) ON DELETE SET NULL
);
CREATE TABLE functor_property_assignments (
functor_id TEXT NOT NULL,
property_id TEXT NOT NULL,
is_satisfied INTEGER NOT NULL CHECK (is_satisfied IN (TRUE, FALSE)),
reason TEXT NOT NULL CHECK (length(reason) > 0),
is_deduced INTEGER NOT NULL DEFAULT FALSE CHECK (is_deduced in (TRUE, FALSE)),
position INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (functor_id, property_id),
FOREIGN KEY (functor_id) REFERENCES functors (id) ON DELETE CASCADE,
FOREIGN KEY (property_id) REFERENCES functor_properties (id) ON DELETE CASCADE
);