docs: ADR-0043 compound-PK foreign-key references (T3); accepted

Audit found single-column FK woven through ~15-20 sites; earns an
ADR. Decision: reference the parent's full compound PK, matched
positionally to an equal-length child list, per-pair type compat.
DSL `from P.(a,b) to C.(x,y)`; SQL `FOREIGN KEY (x,y) REFERENCES
P(a,b)` with bare-FK auto-expansion. Storage follows the existing
primary_key: [...] list convention (yaml columns: [a,b], uniform
JSON in unchanged metadata TEXT cols); back-compat not required,
so no migration. Also marks T3's verified scope.
This commit is contained in:
claude@clouddev1
2026-06-09 17:01:38 +00:00
parent 1d898adf00
commit 274e2b17b7
3 changed files with 279 additions and 4 deletions
+18 -4
View File
@@ -405,10 +405,24 @@ since ADR-0027.)
(`with pk a(int),b(int)`), **storage** (`primary_key:
Vec<String>`), and **display** are present and tested.
**Missing: a FK that *references* a compound PK** —
`db.rs:6822-6836` enforces a single `parent_column: String`;
a bare `REFERENCES parent` on a compound-PK table is refused as
ambiguous, and multi-column FK target syntax is not in the
grammar. This is the one open end-to-end leg of T3.)*
`db.rs` resolve/alter FK paths enforce a single
`parent_column: String`; a bare `REFERENCES parent` on a
compound-PK table is refused as ambiguous, and multi-column FK
target syntax is not in the grammar. This is the one open
end-to-end leg of T3 — but a **codebase audit (2026-06-09)
found it is not a small finish**: single-column FK is woven
through ~1520 sites across 6+ files — the
`__rdbms_playground_relationships` table schema, the
`RelationshipSchema` struct, the **`project.yaml` relationship
format** (`RawEndpoint { column }`), both grammar surfaces
(`add 1:n relationship` + SQL `FOREIGN KEY`), the executor's FK
DDL emission, and the per-column type-compat check. It needs a
**migration** (the metadata-table + yaml-format change, F3) and
an **ADR** to settle the design forks: compound-PK matching
policy (must an FK reference *all* PK columns, or a subset?),
per-pair type-compat semantics, the yaml multi-column shape, and
back-compat for existing single-column projects. So this leg is
ADR-first, not a sweep item.)*
## Visualizations