mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
68.79k stars 6.08k forks source link

Overlapping Arrow Edges in Large Entity Relationship Diagrams #5409

Open anlai46 opened 3 months ago

anlai46 commented 3 months ago

Description

When attempting to create a large entity relationship diagram using Mermaid's live editor, I encountered an issue where the edges of arrows, which represent different cardinality ratios, overlap and collide into each other. This resulted in a messy and visually unappealing diagram, and can make it difficult to interpret the relationships between entities.

Steps to reproduce

  1. Open the Mermaid live editor
  2. Create a large entity relationship diagram with multiple entities and relationships
  3. Try including multiple different cardinality ratios between entities(one or more, zero or more, exactly one, zero or one)
  4. See how the cardinalities as arrows overlap and collide with each other, especially in denser connected areas of the diagram

Screenshots

Full ER diagram:

image

Diagram Issues:

image

Code Sample

erDiagram
    INSTRUCTOR ||--o{ COLLEGE : DEAN
    INSTRUCTOR o|--|{ SECTION : TEACHES
    INSTRUCTOR o|--|{ DEPARTMENT : EMPLOYS
    INSTRUCTOR o|--|{ DEPARTMENT : CHAIR
    INSTRUCTOR {
        string registrationNumber PK
        string make
        string model
        string[] parts
    }
    DEPARTMENT ||--|| COLLEGE : ADMINS
    DEPARTMENT ||--o{ STUDENT : HAS
    DEPARTMENT ||--o{ COURSE : OFFERS
    DEPARTMENT ||--o{ INSTRUCTOR : EMPLOYS
    DEPARTMENT ||--o{ INSTRUCTOR : CHAIR
    DEPARTMENT {
        string driversLicense PK "The license #"
        string(99) firstName "Only 99 characters are allowed"
        string lastName
        string phone UK
        int age
    }
    COLLEGE one to one INSTRUCTOR : DEAN
    COLLEGE O|--|{ DEPARTMENT : ADMINS
    COLLEGE {
        string CName 
        string COffice
        string CPhone
    }
    COURSE ||--|| SECTION : SECS
    COURSE ||--|| DEPARTMENT : OFFERS
    COURSE {
        string CName 
        string COffice
        string CPhone
    }
    SECTION ||--|| INSTRUCTOR : TEACHES
    SECTION ||--|| STUDENT : TAKES
    SECTION ||--|| COURSE : SECS
    SECTION {
        string CName 
        string COffice
        string CPhone
    }
    STUDENT ||--|| SECTION : TAKES
    STUDENT ||--|| DEPARTMENT : HAS
    STUDENT {
        string CName 
        string COffice
        string CPhone
    }

Setup

Suggested Solutions

Additional Context

ArtjomE commented 3 months ago

@anlai46 here reported issue #2291 by me might not be the same, but in my opinion, still lead to the same overlapping issue in displaying the arrows.