relations
Typed edges between identities, such as works_at (person → company)
What you'll learn
You're writing SQL that reads relations and need its columns, what each holds, and the DDL as the spec states it.
- every column and its type
- what the object holds and who writes it
- the DDL as the spec states it
A table. Typed edges between identities, such as works_at (person → company)
Columns
| Column | Type | Constraints |
|---|---|---|
from_id | TEXT | NOT NULL REFERENCES identities(id) |
relation | TEXT | NOT NULL |
to_id | TEXT | NOT NULL REFERENCES identities(id) |
created_at | TEXT | NOT NULL |
Table constraints: PRIMARY KEY (from_id, relation, to_id).
Definition
From spec/ledger.sql, which is the machine-checkable form of SPEC.md §3:
CREATE TABLE relations (
from_id TEXT NOT NULL REFERENCES identities(id),
relation TEXT NOT NULL, -- e.g. 'works_at'
to_id TEXT NOT NULL REFERENCES identities(id),
created_at TEXT NOT NULL,
PRIMARY KEY (from_id, relation, to_id)
);
Used in
- Traverse a relation: The table the relation rows in this guide come from