ER Diagram
An entity relationship (ER) diagram is a type of diagram that models a database schema: it shows the entities in a system, the attributes each entity has, and how entities relate to one another — for example, one user placing many orders.
Design database schemas and entity relationships using Mermaid syntax. Instant visual preview as you type.
Last updated: · Mermaid v11
Plan and document relational schemas before writing a single migration. Typed attributes with PK and FK markers plus explicit cardinalities catch modeling mistakes while they are still cheap to fix.
Show the data model underlying your API resources and how they relate. An ER diagram beside the endpoint reference answers the what-does-this-return-and-how-does-it-join questions before anyone has to ask.
Give new team members the shape of the data in one picture: entities, keys, and one-to-many relationships. Far faster to absorb than reading a stack of CREATE TABLE statements.
erDiagramDeclare diagram typeENTITY { }Define an entity with attributesint id PKPrimary key attributeint fk FKForeign key attributestring email UKUnique key attributeA ||--|| BOne-to-one relationshipA ||--o{ BOne-to-many relationshipA }o--o{ BMany-to-many relationship: "label"Relationship labelOpen FlowViz and start with erDiagram.
Define each entity with its name and an opening brace: USERS {.
Add attributes inside the braces: type name constraint (e.g. int id PK).
Close each entity with }.
Define relationships between entities on new lines: USER ||--o{ ORDER : "places".
Use || for exactly one, o{ for zero or many, |{ for one or many.
Add a quoted label after the colon to describe the relationship.
Export your schema diagram as SVG.
Use an ER diagram for data at rest: tables, their columns and keys, and the cardinality between them. Use a class diagram for behaviour: types, the methods they expose, and how they inherit from one another. They look similar when a class maps one-to-one onto a table, but ER notation says nothing about methods and class notation says nothing about cardinality — so pick by which of those two you actually need to communicate.
Designing and documenting database schemas: the entities, their attributes, and how tables relate to each other.
With the connector symbols: ||--o{ is one-to-many, ||--|| is one-to-one, and }o--o{ is many-to-many.
Yes — attributes go inside the entity block with a type, a name, and optional PK or FK markers.
No signup. No install. Just open the editor and start writing.