Basic example
Entity names are often capitalized, although this is not required in Mermaid.
Entities with attributes
Define attributes with their types:Syntax
Entities and relationships
Each statement consists of:Relationship syntax
The relationship consists of three parts:- Cardinality of the first entity
- Whether the relationship confers identity
- Cardinality of the second entity
Cardinality
Cardinality values
Cardinality values
| Value (left) | Value (right) | Meaning |
|---|---|---|
|o | o| | Zero or one |
|| | || | Exactly one |
}o | o{ | Zero or more (no upper limit) |
}| | |{ | One or more (no upper limit) |
one or more, zero or many, 1+, 0+ are also supported.Identification
Relationships can be identifying (solid line) or non-identifying (dashed line): Using aliases:Attributes
Define attributes with type and name:Attribute keys and comments
Specify primary keys, foreign keys, and comments:Entity name aliases
Use aliases for display names:Unicode and Markdown
Unicode text
Markdown formatting
Direction
Set the diagram orientation:Top to bottom
Left to right
Direction options
Direction options
TB- Top to bottomBT- Bottom to topRL- Right to leftLR- Left to right
Styling
Styling a node
Using classes
With relationships:Configuration
Layout
For larger diagrams, use ELK layout:Requires Mermaid version 9.4+ with lazy-loading enabled.