2026-06-12 · MJ

DBML in five minutes

DBML (Database Markup Language) is a DSL for describing database schemas. It reads like the schema you already have in your head: tables, columns, relationships. Five minutes here covers everything you'll use daily in Schemadrop.

Tables and columns

A table is a block; each line inside is a column with a type and optional attributes:

Table users {
  id uuid [pk]
  email text [unique, not null]
  created_at timestamptz [not null, default: `now()`]
}

The common attributes: pk, unique, not null, increment, and default.

Relationships

Refs connect columns. The > points from the many side to the one side:

Table posts {
  id uuid [pk]
  author_id uuid [not null]
}
 
Ref: posts.author_id > users.id

In Schemadrop you don't even have to type this — drag a connection between two columns on the canvas and the Ref: line is written into your text for you. It's a text edit like any other: it syncs to collaborators and ⌘Z removes it.

Enums

Enum post_status {
  draft
  published
  archived
}
 
Table posts {
  id uuid [pk]
  status post_status [not null]
}

Notes and schemas

Document decisions inline — notes travel with the schema:

Table orders {
  id uuid [pk, note: 'uuidv7 — sortable by creation time']
}

Namespacing works with dotted names: Table billing.invoices { ... } renders as billing.invoices.

Where to go next

Paste any of these snippets into a new diagram and watch the canvas build itself, or keep reading in the docs.