Markdown ER diagram maker

Design a database schema as an entity-relationship diagram. Describe your tables and relationships in Mermaid and get a clean ER diagram to drop straight into your docs.

Mermaid ER syntax

An ER diagram is a set of entities (tables) and the relationships between them. You name each entity, list its fields, then draw a line for each relationship with its cardinality. Here is each piece you can write.

Entities and fields

Name an entity and list its fields inside braces, each as a type then a name. Add PK or FK to mark keys.

You write
erDiagram
  CUSTOMER {
    int id PK
    string name
  }
You get

Relationships and cardinality

Connect two entities. The marks on each end set how many rows relate: one, zero-or-one, or many.

You write
erDiagram
  CUSTOMER ||--o{ ORDER : places
  ORDER ||--|{ LINE : contains
You get

Cheat sheet

Write this You get
Fields
int id PKPrimary key field
int owner_id FKForeign key field
string namePlain field
Cardinality (one end)
||Exactly one
|oZero or one
}o / o{Zero or many
}| / |{One or many
Relationship
A ||--o{ B : labelSolid (identifying) relationship
A ||..o{ B : labelDashed (non-identifying)