Database Schema Diagrams
Visualize your database schema with Mermaid ER diagrams. Import SQL CREATE TABLE statements directly or write Mermaid syntax to define entities, attributes, primary keys, foreign keys, and relationships. Perfect for database design, documentation, and migration planning.
Why Use Mermaid
- Import SQL DDL — Paste CREATE TABLE statements and get an ER diagram instantly
- Auto-detect relationships — Foreign keys are converted to crow's foot notation
- Multiple SQL dialects — PostgreSQL, MySQL, SQLite, and SQL Server supported
- Visual documentation — Generate diagrams for database reviews and onboarding
- Export anywhere — PNG for docs, SVG for presentations, PDF for printouts
Example Diagram
erDiagram
USER ||--o{ ORDER : places
USER ||--o{ ADDRESS : "has"
ORDER ||--|{ ORDER_ITEM : contains
ORDER ||--|| PAYMENT : "paid by"
PRODUCT ||--o{ ORDER_ITEM : "included in"
CATEGORY ||--o{ PRODUCT : groups
USER {
uuid id PK
string email UK
string name
string password_hash
timestamp created_at
timestamp updated_at
}
ORDER {
uuid id PK
uuid user_id FK
string status
decimal subtotal
decimal tax
decimal total
timestamp ordered_at
}
ORDER_ITEM {
uuid id PK
uuid order_id FK
uuid product_id FK
int quantity
decimal unit_price
decimal line_total
}
PRODUCT {
uuid id PK
string name
string sku UK
decimal price
int stock
uuid category_id FK
text description
}
CATEGORY {
uuid id PK
string name UK
uuid parent_id FK
string slug UK
}
ADDRESS {
uuid id PK
uuid user_id FK
string street
string city
string state
string zip
string country
}
PAYMENT {
uuid id PK
uuid order_id FK
string provider
string transaction_id UK
decimal amount
string status
timestamp paid_at
}Copy this code and paste it into the editor to see it rendered live.
Try This Diagram Now
Open the editor with live preview, autocomplete, and export to PNG, SVG, or PDF.
Open EditorFrequently Asked Questions
More Use Cases
Microservices Architecture Diagrams
Document your microservices architecture with Mermaid flowcharts. Visualize service dependencies, API gateways, message queues, databases, and communication patterns. Diagrams as code means your architecture docs live alongside your code and stay up-to-date.
API Documentation Diagrams
Document your APIs visually with Mermaid. Sequence diagrams show request/response flows between clients and services. Flowcharts illustrate authentication flows and error handling. ER diagrams define your data models. All rendered directly in your GitHub or GitLab docs.
CI/CD Pipeline Diagrams
Document your CI/CD pipelines with Mermaid flowcharts. Visualize build stages, test suites, deployment environments, approval gates, and rollback procedures. Since Mermaid renders in GitHub, your pipeline docs live right next to your pipeline code.
System Design Diagrams
Visualize system designs with Mermaid for architecture reviews, technical interviews, and documentation. Use flowcharts for high-level architecture, sequence diagrams for data flows, and C4 diagrams for hierarchical decomposition. Text-based diagrams iterate faster than whiteboard drawings.