Skip to content

Data

Data is always shared: an entity lives under shared/data/, its id starts with data., and every capability that uses it links to it. It holds the product-significant part of the schema, with exact names and types.

writerwriter_idPKemailUKnotenote_idPKwriter_idFK · I1·1textcheckcreated_atI1·2archived_atI1·where · I2·110..manyon delete: cascade

The two tables below: a writer has many notes, and the badges show which index each column is in.

{
"ready": 3,
"kind": "entity",
"id": "data.notes",
"display_id": "DATA-NOTE",
"entity_kind": "table",
"table": "note",
"name": "Note",
"summary": "One note a writer saved.",
"columns": [
{ "name": "note_id", "type": "TEXT", "keys": ["PK"] },
{
"name": "writer_id",
"type": "TEXT",
"keys": ["FK"],
"fk": {
"entity": "data.writers",
"column": "writer_id",
"on_delete": "cascade",
},
"nullable": false,
"indexes": ["I1·1"], // first key of index I1
},
{
"name": "text",
"type": "TEXT",
"nullable": false,
"check": "length(text) <= 10000",
"constants": ["constant.max-note-length"],
"rule": "At most the length limit",
},
{
"name": "created_at",
"type": "TEXT",
"nullable": false,
"indexes": ["I1·2"],
},
{
"name": "archived_at", // holds the Note lifecycle's state
"type": "TEXT",
"nullable": true,
"indexes": ["I1·where", "I2·1"],
"rule": "Set when the writer archives the note; empty while it is active",
},
],
"indexes": [
{
"id": "I1",
"name": "note_writer_active_idx",
"columns": ["writer_id", "created_at DESC"],
"where": "archived_at IS NULL",
"purpose": "Lists a writer's active notes newest first",
},
{
"id": "I2",
"name": "note_archived_idx",
"columns": ["archived_at"],
"where": "archived_at IS NOT NULL",
"purpose": "Finds archived notes past the retention period",
"serves": ["library.purge-archived"],
},
],
"relationships": [
{
"to": "data.writers",
"on": [{ "from": "writer_id", "to": "writer_id" }],
"from_card": "0..many",
"to_card": "1",
"link": "fk",
"on_delete": "cascade",
"label": "A writer has many notes; deleting the writer deletes them",
},
],
}

Its states are its lifecycle, and facts it always keeps true are invariant rules.

Field Req. Meaning
table yes Physical table or view name, file/object path, or non-DB storage location (doc, sheet, folder, inbox)
name yes The name for people
columns yes One per column or key field that determines behavior
entity_kind no table, view, object, projection, external, document, spreadsheet, file, folder, or inbox
schema no The database schema
primary_key no A composite key, in order (entity.column)
indexes no Product-significant indexes, one badge each
relationships no One per foreign key, and one per logical link (with a reason)
column_groups no [{ name, display_id?, columns, summary? }]
derivations no [{ by, columns, text }]: columns another process computes
checks no [{ name?, expr, purpose? }]
coordination no Leases, locks, admission limits, fences: [{ id, coordination_kind?, …, text }]
triggers no Database triggers: [{ name, timing?, event?, does }]
access no { rls?, grants?, readers?, writers? }
view, projection_of no For a view or a projection
volume no Expected size or growth

name and type are required. Optional: keys (PK, FK, UK for database tables/views; ID for an identifying field and LINK for a logical reference on non-database stores such as documents, spreadsheets, files, folders, or inboxes), fk ({ entity, column, on_delete?, on_update? }), nullable, default, check, values, generated, visibility, rule, indexes, constants.

id (the badge: I1, U1, P2), name, and purpose are required. Optional: display_id, requested_by (a capability), unique, method, columns, include, where, params, definition, serves (sequence ids).

Column badges: U1·1 (first key), P1·where (in the predicate), P1·expr, I2·inc (included). Badges use the middle dot, and an unknown one is entity.index.

Field Req. Meaning
to yes The other entity
link yes fk, or logical for a link the product keeps consistent
label yes The relationship in words
on no [{ from, to }] column pairs
from_card, to_card no 1, 0..1, 0..many, 1..many, or bounded like 0..2, as text
on_delete no e.g. cascade
reason no Why a logical link has no foreign key

Document stores: with no foreign keys, model relationships from paths, reference fields, and invariants. The label or reason names the kind (embedded, path, reference, mirror, snapshot, derived) and what keeps it consistent. Containment never implies a cascading delete.

One data diagram over several tables, and the home of their data-level rationale.

{
"ready": 3,
"kind": "data_group",
"id": "data.note-data",
"display_id": "DATA-NOTES",
"title": "Note data",
"summary": "Writers and the notes they keep.",
"entities": ["data.writers", "data.notes"],
"rationale": "Every note belongs to exactly one writer, so deleting a writer deletes their notes and nothing is left without an owner."
}
Field Req. Meaning
title yes The group’s name
entities yes The entities shown together
diagram no A flow drawn with the data, shaped like a rule’s decision
parts, part_of no Parts

An ops[].entity may name a data group, for an operation across its tables.