What is the difference between ER Diagram using UML notation and UML Class Diagrams? [closed]
Asked Answered
B

1

1

I have a project which requires me to create a UML Class Diagram. What I have from the previous tasks in the same project is an ERD using UML notation. Also worth noting, this project is related to database and does not have much coding in it, so creating a class diagram based on other coding is probably not the main objective here.

I tried Googling "how to convert erd to class diagram" but all the search result only shows how to convert ERD using Crow's Feet notation into UML Class Diagram.

I also Googled about UML notation ERD, and found this site which said,

In UML notation, entities are modeled as a “class” with an Entity stereotype.

Does that mean that ERD using UML notation is the same with UML Class Diagram? If not, what are the differences?

Note: I know there are already questions regarding difference between ERD and Class Diagram, but I am asking specifically about ERD using UML notation.

Bradney answered 30/1, 2021 at 6:40 Comment(4)
what is an "ER Diagram using UML notation" ? where can we found the standard defining what it is ? In UML a class can be much more than a container of attributes (e.g. an entity), and in UML you can model much more than just classes. It is impossible for us to know what you have to do using UML, perhaps to go further adding behavior ?Womack
ERD using UML notation which looks exactly how? I can't imagine.Chickabiddy
@qwerty_so, sorry for the late reply, here are a couple of examples I can find from my university slides, image 1 image 2 My university uses this notation and I find it weird that there are so little result when searching for that specific notation on the Internet.Bradney
That's not an ERD, that's pure UML.Chickabiddy
A
2

In Chen's original ERD notation attributes are ovals connected to their entity which is represented with rectangles, which can have relationships represented with losanges. This resulted in very large and complex diagrams, due to the many attributes.

Crow's Feet notation became therefore more popular since it allowed to express the same models in a more compact way, grouping attributes together with their entity in the rectangles, and using an intuitive visual representation of cardinality. But now that UML is the Lingua Franca of modellers, it's tempting to look at other alternatives.

Your linked source suggests a very natural mapping of the core ERD concepts of entity, attribute, relationships, into the UML class, properties and associations:

(...) entities are modeled as a “class” with an Entity stereotype.

(...) attributes can be arranged in a box style (...)

Relationships are shown as a single solid line connecting the two entities. The minimum and maximum cardinalities are shown along the line and verb phrases can be added to completely characterize the nature of the relationship.

And indeed, the most suitable notation for an ERD diagram in UML would be a class diagram.

Beware however of the subtle semantic differences. For example:

  • in UML any property (what your mapping relates to attribute) could be modelled either within the box (as what you call an attribute) or as a related associated class (as what you call an entity) with an owned association end.

  • UML classes are expected to have behavior (it's because of the underlying OOP concepts). Having classes without behavior can be misunderstood by UML reader as a bad design (anaemic domain model). The «Entity» stereotype is not sufficient to disambiguate, since it's in general associated in the UML context with the Entity-Control-Boundary paradigm, which also expects entities to have behavior. Maybe you define an UML profile using a less ambiguous stereotype such as «Data-Entity»

  • Your linked source is misleading about Crow's feet transposition in UML: you can add a verb phrase on an association in UML, but in the middle oc the association and with and with an arrow head next to the text to show the direction of the reading. In UML, the text at an association end is something completely different: it's called "role". The equivalent in an ERD diagram would be to include an attribute with the role name in the entity at the other end (and which would correspond the the primary key identifying the other entity).

A better source about how to note ERD concepts in different notations can be found in the side-bar of the Wikipedia article on ERD.

Edit: A mapping algorithm is proposed in a more general article "A framework for transforming structured analysis and design artifacts to UML": it mentions that in addition, ERD diagrams sub-type relations should be transformed in UML generalization under the condition that it's an IsA relation.

Almazan answered 30/1, 2021 at 12:4 Comment(3)
Hi, thank you for your answer. It's honestly surprising that there are no mentions of UML notation ERD in the Wikipedia and very little in the Internet. I wonder why our university would teach us something that is almost non-existent in real world application.Bradney
@Bradney there is indeed only a comparative diagram in the ERD article (on a desktop it’s on a right sidebar, on mobile it’s hidden in the section on cardinalities).Almazan
@Bradney In fact, you may look at it from a different angle. ERD was invented in a time where data and operations had to be separated. Nowadays there is no need to start with ERD. The ellicitation of a domain model that was previously done with ERD is nowadays done with class diagrams. However, if you start as a young engineer, you will certainly encounter a lot of legacy systems that still have ERD documentation. So it is good to know the mapping. Therefore, this is not wasted time ;-) (and now you have an academic paper, you can refer to).Almazan

© 2022 - 2024 — McMap. All rights reserved.