Skip to main content

DBML

DBML creates database schemas from tables, fields, enums, indexes, and references.

Use this type

Use DBML to document relational data models with a concise schema language.

Source format

The source format is Database Markup Language. Enter the source in the diagram.zip editor.

Syntax essentials

  • Declare a table with a Table block.
  • Declare one field on each line.
  • Put field settings in square brackets.
  • Use Ref to define a relationship.

Example

Table users {
id integer [primary key]
name varchar
}

Table diagrams {
id integer [primary key]
user_id integer
}

Ref: diagrams.user_id > users.id
Rendered exampleDrag to pan. Use the wheel or controls to zoom.
100%
This view uses the live diagram.zip renderer.

Upstream reference

DBML documentation