Entity Relationship Diagrams
Last updated
Was this helpful?
Last updated
Was this helpful?
Mermaid's Entity Relationship Diagrams (ERDs) help you visualize database structures and relationships. For analytics engineers, they're essential for documenting data models, table relationships, and database schemas. ERDs show how different entities (tables) in your database relate to each other, including their attributes and the nature of their relationships.
From the Code IDE, Click Apps and Agents from the lefthand panel
Select Mermaid. Paradime will automatically start a new mermaid project
In the terminal that appears, use the arrow keys to select "Entity Relationship Diagrams"
A new entityRelationshipDiagram.mmd
file will be created in your editor with this starter template:
---
title: Order example
---
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
Click the eye icon (👁️) in the top right corner of your Mermaid file to preview the diagram
Edit and update your .mmd
file as needed - the preview will update automatically
erDiagram
FACT_TABLE {
string order_id PK
timestamp created_at
decimal amount
}
Show relationships between entities using crow's foot notation:
||--||
: Exactly one to exactly one
||--o{
: One to many (zero or more)
||--|{
: One to many (one or more)
}o--o{
: Many to many
Solid lines (--): Identifying relationship
Dotted lines (..): Non-identifying relationship
erDiagram
DIM_CUSTOMER ||--o{ FACT_SALES : generates
DIM_PRODUCT ||--o{ FACT_SALES : includes
DIM_DATE ||--o{ FACT_SALES : occurs_on
FACT_SALES {
string sale_id PK
string customer_id FK
string product_id FK
date sale_date FK
decimal amount
}
DIM_CUSTOMER {
string customer_id PK
string name
string segment
}
erDiagram
STG_ORDERS ||--|{ STG_ORDER_ITEMS : contains
INT_ORDERS }|--|| FCT_SALES : transforms_to
STG_ORDERS {
string order_id PK
timestamp created_at
string status
}
Use clear, descriptive entity names
Show only relevant attributes
Include key relationships
Use consistent naming conventions
Document primary and foreign keys
Group related entities together
For more syntax options and advanced features, visit the official Mermaid documentation