Basic Editing Experience
Overview​
You can quickly create database diagrams (ERDs) using DBML to visualize database structures, and define relationships, all without relying heavily on a mouse—perfect for those who prefer coding over dragging and dropping.
How to use dbdiagram:
- In the DBML editor at left pane, type your database schema using DBML syntax.
- Watch the diagram automatically appear on the diagram visualizer in the right as you type.
- Use the toolbar to export your diagram as a PDF/PNG or generate SQL code for your database.
That’s it—start typing and see your schema come to life!
DBML editor​
The DBML editor is powered by Monaco Editor, which is the fully featured code editor from Visual Studio Code.
Keyboard shortcuts​
- Navigate to a diagram element:
Ctrl/Command + F12
orCtrl/Command + Click
- Show/hide editor:
Ctrl/Command + \
- Toggle line comment:
Ctrl/Command + /
- Toggle block comment:
Shift + Alt/Option + A
- Open Command Palette:
F1
- Other shortcuts: Press
F1
to find the shortcut in the Command Palette
Navigate to diagram​
You can quickly navigate/focus to the diagram element by Ctrl/Command + F12
or Ctrl/Command + Click
on code definitions of tables, relationships, and table groups.
Folding​
You can hide extraneous information and focus on the vital part by folding some lines of code. Below is an example of a folded region:
By default, folding regions are automatically created based on the indentation in the code. You can manually define a custom folding region depends on your needs by using the syntax:
// #region
...
// #endregion
Example:
- Line 1 to 14 (unfolded):
- Line 1 to 14 (folded):
Diagram visualizer​
Navigate to code​
You can quickly navigate to the code definition by double-clicking
on tables, columns, relationships and table groups.
View note​
Table or column notes can be viewed by hovering over the table header or column and clicking the Read Full button (markdown supported).
Refer to the doc to learn how to define table and column notes.
Drag and drop to create relationships​
You can quickly create a one-to-many relationship by dragging a primary key field to a foreign key field.