Entity Relationship Diagrams

What are Entity Relationship Diagrams?

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.


Creating Your First ERD

  1. Launch DinoAI: From Code IDE, access DinoAI to start creating diagrams.

  2. Use a Simple Prompt: Tell DinoAI what kind of ERD you want to create. For example:

- "Create a mermaid  ERD diagram showing the relationships between my customer, order, and product tables"

- "Generate a mermaid ERD for my e-commerce data model with proper cardinality notation"

- "Build a mermaid ERD diagram for my dbt models showing table relationships and key columns"
  1. Get Your Diagram: DinoAI will generate a complete .mmd file with proper Mermaid syntax.

  2. Preview Your Work: Click the eye icon (👁️) to preview your diagram in real-time as you edit.

  3. Iterate and Refine: Modify the generated .mmd file directly, or ask DinoAI to make specific changes.

Example

.mmd file
---
title: Order example
---
erDiagram
    CUSTOMER ||--o{ ORDER : places
    ORDER ||--|{ LINE-ITEM : contains
    CUSTOMER }|..|{ DELIVERY-ADDRESS : uses

Reusable ERD prompts for you and your team

You can create custom, standardized .dinoprompts for Mermaid's ERDiagrams that ensure consistency across your data team. See step-by-step guide.


Diagram Syntax Guide

Basic Entity Definition

erDiagram
    FACT_TABLE {
        string order_id PK
        timestamp created_at
        decimal amount
    }

Cardinality Notation

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

Relationship Types

  • Solid lines (--): Identifying relationship

  • Dotted lines (..): Non-identifying relationship


Best Practices

Additional Resources

For more syntax options and advanced features, visit the official Mermaid documentation

Last updated

Was this helpful?