Mermaid diagram types

Mermaid ER diagrams

A Mermaid entity-relationship (ER) diagram describes a database schema as text: entities, their attributes, and crow's-foot cardinality between them (one-to-many, many-to-many). It's the fastest way to sketch a schema before writing migrations — and to keep that sketch in version control.

A classic orders schema with attributes on two entities.

ER diagrams pair naturally with AI generation: describe the product ('a booking app with users, listings, and reservations') and the draft schema appears, ready to refine.

When to use a er diagram

  • Schema design before writing SQL migrations
  • Documenting existing databases for new teammates
  • Data-model reviews in pull requests
  • Planning multi-tenant or audit-trail structures

The Mermaid code

Copy it anywhere Mermaid renders — or see the full syntax reference.

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ ORDER_ITEM : contains
    PRODUCT ||--o{ ORDER_ITEM : "ordered in"
    CUSTOMER {
      string name
      string email
    }
    ORDER {
      string id PK
      date placed_at
    }

Frequently asked questions

How do I create an ER diagram in Mermaid?
Start with `erDiagram` and write one relationship per line: `CUSTOMER ||--o{ ORDER : places` reads as 'one customer places zero-or-more orders'. The symbols are crow's-foot notation: || exactly one, o{ zero or more, |{ one or more, o| zero or one. Attribute blocks in braces list `type name`, with PK/FK markers.
What does ||--o{ mean in Mermaid?
It's the cardinality of the relationship, read from each end: || means exactly one, and o{ means zero or more. So `A ||--o{ B` is a one-to-many relationship — one A relates to many B rows. Use |{ for one-or-more and o| for zero-or-one.
Can I generate an ER diagram from a description or SQL?
Yes. Paste a description of the product or an outline of your tables into MermaidCreator's AI and it drafts the entities, attributes, and relationships as Mermaid you can keep editing visually or in code.

ER diagram templates

Other Mermaid diagram types