ER Diagram
Design database schemas and entity relationships using Mermaid syntax. Instant visual preview as you type.
erDiagram
USER {
int id PK
string email UK
string name
datetime created_at
bool is_active
}
PRODUCT {
int id PK
string name
decimal price
int stock
int category_id FK
}
ORDER {
int id PK
int user_id FK
decimal total
string status
datetime ordered_at
}
ORDER_ITEM {
int id PK
int order_id FK
int product_id FK
int quantity
decimal unit_price
}
CATEGORY {
int id PK
string name
}
USER ||--o{ ORDER : "places"
ORDER ||--|{ ORDER_ITEM : "contains"
PRODUCT ||--o{ ORDER_ITEM : "included in"
CATEGORY ||--o{ PRODUCT : "has"Plan and document relational database schemas before writing migrations.
Show the data model underlying your API resources and their relationships.
Communicate data structure to new team members and stakeholders.
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.
No signup. No install. Just open the editor and start writing.