erDiagramv0.9.4

What is a ER diagram?

Entity-relationship models for databases.

erDiagramCUSTOMERid PKemailcreated_atPRODUCTsku PKtitlepriceORDERid PK · cust_id FKplacescontains
When to use it

Use a ER when…

01

Database schema documentation

02

Domain modeling for new features

03

Onboarding for the data layer

Syntax basics

The minimal syntax

Copy this and you have a working er. Build from here.

er.mmd
erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE_ITEM : contains
    PRODUCT ||--o{ LINE_ITEM : appears_in
    CUSTOMER {
      uuid id PK
      string email
      datetime created_at
    }
CUSTOMERid PKemailcreated_atPRODUCTsku PKtitlepriceORDERid PK · cust_id FKplacescontains
Common patterns

Patterns worth memorizing

Crow's-foot notation

`||--o{` is one-to-many; `}o--o{` is many-to-many. Memorize the four shapes.

Attribute keys

`PK`, `FK`, `UK` after a column type render as small badges.

Relationship verbs

The `: writes` part is the verb on the line; pick a verb that reads in both directions.

Common gotchas

The things that will trip you up

Mermaid silently ignores misspellings — these are the failures we see most.

  1. 01

    Entity names should be UPPERCASE for cleanest rendering.

  2. 02

    You cannot style individual columns — only the relationship line.

  3. 03

    Long attribute lists make the box tall; consider splitting into linked sub-entities.