Skip to main content

Examples

Every diagram on this page is a plain ```dbml fence in this page's source. Click Code on any of them to see the exact DBML.

The schemas are deliberately small, so the feature being shown is visible without panning. For everything at once, see the Showcase.

The minimum​

A table and its columns. No options, no relationships.

Column settings​

Primary keys, auto-increment, not null and unique all render as badges. Defaults are rendered by kind, so an expression does not read as a string literal. Notes attach to the column they document.

Note the alias (as U), the custom headercolor, and the table-level note.

Enums​

Enums render as their own nodes, including any enum nothing references — so a lookup type you have defined but not wired up yet is still visible.

currency_code is referenced by nothing and still appears.

Relationships​

Inline refs, standalone Ref: blocks, one-to-one, one-to-many, a self reference, a named ref with its own colour and delete action, and a documented but unenforced [inactive] ref drawn dashed.

Hover a column to highlight everything it connects to.

Optional and many-to-many​

The >? and <> operators need @dbml/core v10 — on v5 they do not parse at all.

Cardinality is drawn at each end of the edge: 1, 0..1, *, 0..*.

Indexes and checks​

Both get their own section under the columns.

Composite keys and composite refs​

A composite reference pairs its columns positionally and draws one edge per pair — not a single edge implying the other columns are uninvolved.

Groups, sticky notes and schemas​

Table groups draw as a labelled backdrop behind their members. Sticky notes are free-floating Note blocks. Tables in different schemas can reference each other.

This one is set to height=650, because the default 500 crops it.

Height, both ways​

The same schema twice. This one is height=250:

And this one is height=50vh — a share of the viewport rather than a pixel count, so it scales with the window: