Database relationship modeling

Mermaid ER Diagram Online Editor

Create a Mermaid ER diagram online to model database entities, attributes, primary and foreign keys, cardinality, and relationship meaning. Preview the ERD and export it as SVG or PNG.

Build a Mermaid ER diagram online

Start with customers, orders, and line items, then edit keys, attributes, cardinality, and relationship labels while the ERD stays visible.

Build a Mermaid ER diagram online

Changes render automatically in the preview.

er-diagram.mmd17 lines
Live previewWaiting

Open full editor

Review data structure and cardinality together

A Mermaid ER diagram keeps entities, selected attributes, keys, and relationships in text that can be reviewed beside schema changes and documentation.

Explicit cardinality

Show required, optional, one, and many constraints on both ends of a relationship.

Keys and attributes

Document the fields relevant to the model and mark primary, foreign, or unique keys.

Live Mermaid preview

See the rendered result update as you edit and keep syntax feedback beside the source.

No local setup

Work in a modern browser without installing Mermaid CLI, a desktop app, or an editor extension.

Continue in OnUML

Move the current source into the full editor for AI generation, repair, sharing, and saved projects.

How to create a Mermaid ER diagram

Model one database concern at a time, then verify that every relationship and key expresses a real data constraint.

  1. 01

    List the entities needed to answer the current database design question.

  2. 02

    Add only the attributes and keys relevant to relationships, identity, and review.

  3. 03

    Connect entities with cardinality symbols that match optionality and multiplicity.

  4. 04

    Label each relationship with a short verb that reads naturally between entities.

  5. 05

    Check the rendered ERD, then export it or continue in the full editor.

Mermaid ER diagram syntax and modeling choices

An effective ERD makes ownership, optionality, and cardinality clear without duplicating every database column or implementation detail.

Choose entity boundaries first

Start from concepts that have their own identity and lifecycle. Avoid turning every field or lookup value into a separate entity.

Read cardinality from both ends

Check whether each side is optional or required and whether it permits one or many records. The two endpoints together define the constraint.

Mark keys that explain relationships

Include PK, FK, and UK markers when they clarify identity, references, or uniqueness, while leaving unrelated columns out of a focused diagram.

ER diagram vs class diagram

Use an ER diagram for persisted entities, keys, and database cardinality. Use a class diagram for software behavior, interfaces, and inheritance.

Mermaid ER diagram example

The example models customers placing orders that contain line items, with primary, foreign, and unique key annotations.

erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE_ITEM : contains
    CUSTOMER {
        string id PK
        string email UK
    }
    ORDER {
        string id PK
        string customer_id FK
        date created_at
    }
    LINE_ITEM {
        string order_id FK
        string sku
        int quantity
    }

Compare ER notations

Mermaid vs PlantUML for ER diagrams

Compare syntax, relationship notation, database modeling depth, and maintainability for text-based ERDs.

Read the ER diagram comparison

Frequently asked questions

What is a Mermaid ER diagram online editor?

It is a browser tool for writing Mermaid erDiagram syntax, previewing entities and relationships, and exporting the ERD as SVG or PNG.

Can Mermaid ER diagrams show one-to-many relationships?

Yes. Mermaid relationship endpoints express one, zero-or-one, one-or-more, and zero-or-more cardinality.

Can I add primary and foreign keys?

Yes. Attribute definitions can include PK, FK, and UK markers to document key roles.

Should an ER diagram include every column?

Usually no. Include columns that explain identity, relationships, constraints, or the design question being reviewed.

Can I export the ER diagram as SVG or PNG?

Yes. Preview the ERD, then download SVG for scalable documentation or PNG for image-based sharing.

When should I use a class diagram instead?

Use a class diagram when methods, interfaces, inheritance, and software responsibilities matter more than persisted data relationships.