feat: add "Using the playground" section + Reference skeleton
Restructure the docs into five top-level sections, splitting the application you drive from the database language you build with. - New "Using the playground" section: command-line options; the assistive editor (completion, highlighting, [ERR]/[WRN] indicator, hints, in-line editing); the output pane (scrolling); projects (save/load/new/rebuild); undo/redo & history; export & import; clipboard; getting help. Grounded in the in-app help/usage and ADR-0003/0022/0027. - Reference: seed the remaining topic pages (Columns, Relationships, Indexes, Constraints, Inserting & editing data, Querying & inspecting) with real syntax synopses; worked examples to follow. - Surface the assistive editor on the landing page and in Getting started; restore cross-links now that targets exist. Plan + STYLE updated to the five-section structure. 24 pages, build green, links resolve, content clean; planned features carry "planned" callouts.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Relationships
|
||||
description: Declare and remove foreign-key relationships between tables.
|
||||
sidebar:
|
||||
order: 4
|
||||
---
|
||||
|
||||
:::note[In progress]
|
||||
The syntax below is complete and accurate; worked examples on the library
|
||||
schema are being added.
|
||||
:::
|
||||
|
||||
A relationship is a foreign key from a child table to a parent's primary
|
||||
key. In simple mode:
|
||||
|
||||
```rdbms-syntax
|
||||
add 1:n relationship [as <Name>]
|
||||
from <Parent>.<col> to <Child>.<col>
|
||||
[on delete <action>] [on update <action>]
|
||||
[--create-fk]
|
||||
drop relationship <Name>
|
||||
```
|
||||
|
||||
`<action>` is `cascade`, `set null`, or `restrict`. `--create-fk` adds the
|
||||
child column if it doesn't exist yet.
|
||||
|
||||
**Compound keys.** To reference a parent's compound primary key, list the
|
||||
columns on each side, matched in order:
|
||||
|
||||
```rdbms-syntax
|
||||
add 1:n relationship from <Parent>.(<a>, <b>) to <Child>.(<x>, <y>)
|
||||
```
|
||||
|
||||
In advanced mode, relationships are declared with `FOREIGN KEY … REFERENCES`
|
||||
in `CREATE TABLE` or `ALTER TABLE`.
|
||||
|
||||
See also [Indexes](/reference/indexes/) and [Types](/reference/types/) (why a
|
||||
foreign-key column's type can differ from the key it references).
|
||||
Reference in New Issue
Block a user