Mermaid: ER diagram attributes

Created on 22 Apr 2020  路  1Comment  路  Source: mermaid-js/mermaid

Thanks a ton to @spopida for adding ER diagrams to mermaid in #1308!

As mentioned in the docs, attributes are not yet supported.

ER diagrams are a new feature in Mermaid and are experimental. There are likely to be a few bugs and constraints, and enhancements will be made in due course. Currently you can only define entities and relationships, but not attributes.

It would be awesome if there could be attributes for an entity similar to how classes have members.

Class diagrams unfortunately don't allow to specify relations between their fields. If I understand the distinction correctly, this would be possible with ER diagrams that support attributes.

Attributes for an entity would allow to make diagrams of object models like the following.

er diagram

Triage Enhancement

Most helpful comment

Hi @zjopy - glad you like the ER diagram feature, and thanks for posting your suggestion. Ability to add attributes is definitely something I would like to do, although I'm not quite sure when! It's my top priority for the next enhancement (if someone doesn't beat me to it!).

Getting the lines to connect to the exact 'correct' place is likely to be challenging, because layout of the diagram is delegated to a rendering engine (dagre), so there is not so much control over where the edges (lines) intersect with the nodes (boxes). But we'll see.

In fact I have a general concern about including foreign keys as attributes, although I know they will be popular and 'everyone does it'. My concern is that the inclusion of a foreign key attribute turns a _logical_ ER model, that could be implemented in various ways, into a _physical_ ER model that follows the relational approach. For example, you can implement a one-to-many relationship in JSON without the need for a foreign key using an array property embedded in the parent entity.

Of course it's not for me to stipulate why people should or shouldn't use physical or logical models, so I think it's perfectly OK to allow foreign key attributes in the diagram. I just want to be careful not to imply that all relationships 'need' foreign key attributes.

Anyway, it's on my radar, and thanks for raising it.

>All comments

Hi @zjopy - glad you like the ER diagram feature, and thanks for posting your suggestion. Ability to add attributes is definitely something I would like to do, although I'm not quite sure when! It's my top priority for the next enhancement (if someone doesn't beat me to it!).

Getting the lines to connect to the exact 'correct' place is likely to be challenging, because layout of the diagram is delegated to a rendering engine (dagre), so there is not so much control over where the edges (lines) intersect with the nodes (boxes). But we'll see.

In fact I have a general concern about including foreign keys as attributes, although I know they will be popular and 'everyone does it'. My concern is that the inclusion of a foreign key attribute turns a _logical_ ER model, that could be implemented in various ways, into a _physical_ ER model that follows the relational approach. For example, you can implement a one-to-many relationship in JSON without the need for a foreign key using an array property embedded in the parent entity.

Of course it's not for me to stipulate why people should or shouldn't use physical or logical models, so I think it's perfectly OK to allow foreign key attributes in the diagram. I just want to be careful not to imply that all relationships 'need' foreign key attributes.

Anyway, it's on my radar, and thanks for raising it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tokyo786 picture tokyo786  路  3Comments

pirDOL picture pirDOL  路  3Comments

michaeltlombardi picture michaeltlombardi  路  3Comments

chen4221 picture chen4221  路  3Comments

The-Alchemist picture The-Alchemist  路  4Comments