Skip to article
Documentation

Schemas and diagrams

Write a schema and explore relationships, views, and lineage.

On this page

Create a schema#

Create schema.dbml in the project and add two related tables:

Table users {
  id integer [pk]
  name varchar
}

Table posts {
  id integer [pk]
  user_id integer [ref: > users.id]
  title varchar
}

Use completion inside a table, navigate from users.id to its declaration, and invoke Rename on a column to update references safely. Inspections and quick fixes help identify unresolved names and structural mistakes.

Explore the diagram#

Open the DBML diagram associated with the file. Both tables and their foreign-key relationship should appear. Use table or column search to locate a large schema’s objects, zoom to read details, and pan the canvas to move around the diagram. Relationship labels appear on hover.

Choose a detail level appropriate to the task. Key-only views reduce noise when reviewing relationships; expanded records help inspect sample data. Indexed primary and unique keys appear in badges and key-only views.

Focus a view#

Select relevant tables and create a DiagramView to retain a focused subset. Each view keeps an independent layout. Table groups can be colored and collapsed, and sticky notes explain design choices without changing the database model.

Use upstream or downstream lineage tracing when investigating dependencies. A lineage-only diagram intentionally hides unrelated objects. Clear that filter to return to the whole schema.

Compare a Git revision#

Choose Compare with Git Revision… from the DBML editor. Select a revision and review additions, changes, and removed objects, including diagram highlights. The comparison includes imported modules and current unsaved edits, so review the editor state before treating it as a committed-to-committed comparison.

Manual for version 2026.2.4 · Reviewed