Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading direction indicators for ER diagrams #4537

Open
materpillar opened this issue Jun 26, 2023 · 0 comments
Open

Reading direction indicators for ER diagrams #4537

materpillar opened this issue Jun 26, 2023 · 0 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request

Comments

@materpillar
Copy link

Proposal

Mermaid.js should add an option for Entity Relationship diagrams to indicate reading direction of a relationship.
There might be multiple relationships between entities in both directions that shall appear on a diagram.

For example, I want to express a relationship:
A fop can contain 0 or multiple gop.
A gop can call 0 or 1 different fop.

The current available notation will not be able to express this unambigously, as the diagram will imply: A fop can call 0 or 1 gop

erDiagram
    "FOP" ||--|{ "GOP" : contains
    "GOP" o|--|| "FOP" : calls

image

To workaround this limiation, but only under the precondition of assuming a reading direction from top-to-bottom, one could rename "calls" to "called by". Yet, this stays ambiguous.

The following paragraph from the documentation is in my opinion technically not 100% correct:

For example:
PROPERTY ||--|{ ROOM : contains
This statement can be read as a property contains one or more rooms, and a room is part of one and only one property.

It should read:
A property contains one or more rooms, and a room is partcontained by one and only one property.

In general, the passive voice should be used to reverse a relationship, as anything different will require additional knowledge of the domain (and vocabulary)

The next statement is correct for many cased, but is based on too simplistic assumptions for technical documenation, as I tried to demonstrate in this issue.

When considered from the perspective of the second entity, the equivalent label is usually very easy to infer. (Some ER diagrams label relationships from both perspectives, but this is not supported here, and is usually superfluous).

Example

%%{init: { 'erDiagram': {'directionIndicators': true}} }%%

Screenshots

bitmap

@materpillar materpillar added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant