Manual · The book

# Schema & data

Tables, fields, relationships, computed columns — and what money is.

The schema is a drawing — and the drawing is the database.

## Tables and fields

A table is a card on the canvas; `＋` adds one, and blocks add several fields in one press (an address is four fields). Double-click a field for its editor: type, required, unique, indexed, decimals — and a note, for the colleague who wonders next year. Every table carries four system fields you never manage: `id`, `createdAt`, `modifiedAt` and `revision`, which counts every effective save and is what multi-user safety leans on.

The data browser draws the four system fields as ordinary columns — including the `revision` that multi-user safety leans on.

## Relationships

Drag from one table to another. Neuridion writes the foreign key, and the relationship reads like a property from both sides: `invoice.customer`, `customer.invoices`. The delete rule is a decision, not an accident — prevent (the default, the only one that can never lose data), cascade, or nullify.

## Computed fields

A computed field is a real column, filled on the way in — not a formula evaluated when a window happens to look. `invoice.total` as sum of lines.net is stored on every save that touches it, which is why a list of four thousand invoices shows totals instantly: it reads them, it does not compute them.

You write the formula in the field editor — as a sentence for aggregates (“the sum of lines.net”) or as an expression — and it is worked out against a real record while you type, so a wrong path shows itself before you save. Children are computed before parents; and changing a formula is a data migration: on the next save of the project every stored value is refilled, oldest dependencies first.

On a form, bind a label to a computed field and it keeps itself current — a script that writes totals into an unbound label goes stale the moment a cell is edited, which is why the examples never do that.

## Money

Money is the Amount type: an integer count of minor units — cents — never floating point, so sums are exact to the last cent. An Amount carries its currency wherever it is drawn, form and list alike, with no option to forget it; the field's own scale decides the places (three for a dinar). A plain Number field that should merely look like money has the inspector's show as amount switch.

## Files and pictures

Files and images are columns. A stored file keeps its name, kind, dates and size in the record; the bytes live in a sibling database (`Kundenkartei.files.sqlite`) attached to the same connection — one atomic transaction across both, encrypted together. Lists show “Vertrag.pdf · 2,4 MB” without touching the bytes; the document is read the moment somebody actually asks. How big a single file may be is a project setting (twenty megabytes unless you say otherwise), enforced at the one funnel every writer passes.

## When the schema changes

Save, and the development database follows the model — a safety copy is taken first, columns are added, renamed fields keep their data (identity is matched first, name second), computed fields refill in dependency order. A built application does the same to its customer's database on first launch after an update: an update never touches a customer's data except to migrate it forward, behind a backup.