Skip to main content

Create a diagram

To begin, go to the online editor. If a previous digram gets loaded you can go to File > New and pick the blank diagram option.

New File
Create a blank diagram

Pick a database

You can create database-specific or generic diagrams.

  • Generic diagrams can be imported from or exported to any of the supported SQL flavors, however, they support a fewer number of types.
  • Database-specific diagrams support all data types for the selected database and other database-specific features.

The following databases are supported:

  • MySQL
  • PostgreSQL
  • SQLite
  • MariaDB
  • MSSQL
Pick a database

Tables

Add tables either from the sidebar or the toolbar and define columns.

Define tables

Table Fields

You can define the following fields for a column:

  • Name
  • Datatype
  • Not null
  • Primary
  • Unique
  • Autoincrement
  • Default
  • Check constraint
  • Comment
info

If multiple primary keys are defined a composite primary key will be generated in the SQL output.

info

The check constraint will be injected into the SQL output as is.

Indexes

You can define the following fields for an index:

  • Fields
  • Unique
  • Name

Relationships

To create relationships and define foreign keys, click and hold the blue dot on the foreign key column, then drag and drop it onto the primary column. This action follows the logic of start_col REFERENCES end_col, where the column you drag from will be designated as the foreign key, linking it to the primary key in the destination column.

Create a relationship

E.g. in the image above, since posts.user_id is the foreign key we start dragging from user_id to users.id.

If at some point you realize that the keys are flipped you can swap them from the Relationships tab. Open the relationship you'd like to edit, click on the more button (three dots) next to the primary and forign columns, and then swap.

You can define the following fields for a relationship:

  • Name
  • Cardinality
    • One to One
    • One to Many
    • Many to One
  • On Delete Action
  • On Update Action
    • No action
    • Restrict
    • Cascade
    • Set null
    • Set default
:
How can I define Many to Many relationships?
:

In order to model Many to Many relationships you will need to use a join table.

A join table is a third table that contains foreign keys to the 2 tables you'd like to connect. Additionally, you can add any other relationship-specific columns to the table. For example:

Pick a database

Subject areas

You add subject areas from the Subject Areas tab in the sidebar or from the toolbar. They logically group the tables in subject areas to make it easier to navigate the diagram; they server a pure visual purpose and do not translate to any SQL logic and are not reflected in the generated scripts.

Notes

You add notes from the Notes tab in the sidebar or from the toolbar. You can use notes to capture any additional comments in the diagram.

Custom Types

If the diagram type supports custom types there will be an additional Types tab in the sidebar. In generic diagrams the following conversions will take place when exporing to SQL.

DatabaseBehavior
MySQL/MariaDBA JSON with the corresponding JSON validation check
PostgreSQLA composite type
SQLiteBLOB
MSSQLA type alias to the first field

Upon adding a new type, it will be added to the list of types you can choose from when editing a column.

Enums (PostgreSQL)

If the diagram is for PostgreSQL there will be an additional Enums tab in the sidebar where you can define enum values. Upon adding a new enum, it will be added to the list of types you can choose from when editing a column.