ER diagrams in Confluence

An entity relationship diagram shows the tables of a database, their columns and how the tables are linked.

Last updated

When to use it

Use an ER diagram to document a database schema or to design one before the first migration. Each box is a table with its columns and keys; each line says how many rows on one side match rows on the other, for example one customer to many orders.

Example

This is the code of the Online shop template: customers, orders, order lines and products with keys.

erDiagram
  CUSTOMER ||--o{ ORDER : places
  ORDER ||--|{ ORDER_LINE : contains
  PRODUCT ||--o{ ORDER_LINE : "appears in"
  CUSTOMER {
    int id PK
    string name
    string email
  }
  ORDER {
    int id PK
    date created_at
    string status
  }
  ORDER_LINE {
    int quantity
    decimal unit_price
  }
  PRODUCT {
    int id PK
    string sku
    string name
  }

Vellnar Diagrams draws it like this:

Change a line and the diagram changes with it. Nobody needs the original drawing file, because there is none: the code is the diagram.

Add it to a Confluence page

  1. Edit a Confluence page and type /mermaid where the diagram should go.
  2. Select Mermaid diagram. The editor opens with the template list.
  3. Pick a template, or choose Start blank and paste the code above. The preview follows every keystroke.
  4. Choose Save. The diagram appears on the page.

The documentation covers the editor, the settings and the exports.

Templates

The Templates button in the editor has 3 ER diagrams ready to use:

  • Online shop: Customers, orders, order lines and products with keys.
  • CRM: Accounts, contacts, opportunities and activities.
  • Star schema: A sales fact table joined to date, product, customer and store dimensions.

Syntax

The code of a entity relationship diagram starts with erDiagram. The Mermaid documentation describes every element of the syntax. Vellnar Diagrams draws it with Mermaid 12.3; if a line has an error, the editor marks the line and keeps the last valid diagram on screen.

More

  • Mermaid in Confluence: how diagrams as code work in a page, and every diagram type.
  • Security: the app asks for no permissions and sends nothing outside Atlassian.