How to draw an ER diagram

An entity–relationship diagram shows a database’s tables, their columns and how they join. Draw one to design a schema or explain one.

An ER diagram with users, orders, products and order_items tables, each column with its type and key marks, joined by one-to-many relationships drawn with crow’s feet. An ER diagram with users, orders, products and order_items tables, each column with its type and key marks, joined by one-to-many relationships drawn with crow’s feet.
A shop’s tables: relationships meet the columns they join.

Step by step

  1. Pick ER diagram from the Diagram menu, click Table, then click the board. Type the table’s name, then one column per line: name, data type, then PK, FK or UK.

    A users table: id int PK, email text UK and name text, with the keys in their own column. A users table: id int PK, email text UK and name text, with the keys in their own column.
  2. Or select the table and edit its columns in the panel on the right: a name and a data type for each, PK / FK / UK toggles, and Add column.

    The Columns panel on the right, listing each column of the users table with its type and key toggles. The Columns panel on the right, listing each column of the users table with its type and key toggles.
  3. Add the next table, pick One to many and drag from the “one” table onto the column it joins in the other: the line meets that column.

    An orders table next to users, joined by a one-to-many line that meets its user_id column. An orders table next to users, joined by a one-to-many line that meets its user_id column.

Tips

Mermaid

Paste this onto the board, or use Board menu → Import Mermaid…; Export Mermaid… writes a board back as text.

erDiagram
  users ||--o{ orders : places
  users {
    int id PK
    text email UK
  }
  orders {
    int id PK
    int user_id FK
  }

Ends: || exactly one, |o / o| zero or one, }| / |{ one or more, }o / o{ zero or more. Mermaid writes attributes type first. More on Mermaid import and export.