0

How do you translate this ER relation to UML: enter image description here

This is my attempt: enter image description here

Is this the correct way of doing it? I feel a bit lost.

user1
  • 37
  • 6
  • I don't know ERD well enough, but if the diamond represents an association class your attempt would be right. – qwerty_so Oct 22 '21 at 10:27
  • I’m voting to close this question because it isn't a programming question. It [_might_ be on-topic](https://meta.stackexchange.com/q/134334/248627) on [codereview.se]. – ChrisGPT was on strike Oct 22 '21 at 13:05
  • @qwerty_so, yes, it's a hard one to categorize but I think a question about ER diagrams and UML without _any_ code is objectively off-topic here. Just because somebody here _can_ answer doesn't make it on-topic. – ChrisGPT was on strike Oct 22 '21 at 14:56
  • 1
    @Chris We'll see ;-) The code, however, is the diagram you see. UML is a language and a diagram is a (partial) sentence of the language. Just like a code snippet is a (partial) sentence of the according programming language. So that is a valid question. Probably not one I would get excited about, but valid. – qwerty_so Oct 22 '21 at 19:58
  • @qwerty_so, I strongly disagree and believe that most other users would as well. But since there are no useful, on-topic tags here, very few users will see it and it will therefore take a while to be closed. (I only saw it when it popped up in a review queue.) In general, any question without a language tag is likely off-topic. I see that you yourself have earned most of your reputation on the [tag:uml] and related tags, so you're clearly biased. That doesn't make this a bad question (or make your expertise not useful), it's just off-topic _here_. – ChrisGPT was on strike Oct 22 '21 at 20:02
  • @Chris UML and its diagram is in scope on SO. Thousands of UML questions here with thousands of answers demonstrate this point. Moreover, I’d argue that leading UML tools can do roundtrip engineering, creating diagrams from code and generating code from diagrams. (The same applies to ERD models). I’d therefore pretend that UML diagrams is equivalent to code. If you do not like diagramming questions, you can just ignore them and look for questions with other tags. – Christophe Oct 23 '21 at 00:07
  • @Christophe, whether UML is on-topic or not, questions asking "is this [code | diagram] correct?" are _not_. The asker is mean to tell _us_ that a problem exists, and what it is. This is a review-my-work question and therefore _off-topic_. – ChrisGPT was on strike Oct 23 '21 at 00:24
  • @Chris Ok, I misunderstood. Yes, this would be a good idea to put diagram reviews on code reviews. In some cases however, the specific diagram hides a more general question that help other diagrammers as well. – Christophe Oct 23 '21 at 00:40
  • @Chris I have to admit that many questions tagged UML are actually review questions and often I'm reluctant to answer. However, it seems fine then when I read one of Christophe's answers where there's some tutorial in it where others can gain knowledge too. I see that many questions are repeated with only slight changes: hard to nail the pudding to the wall. I understand your point, but rest assured that there are people having an eye on this. There are just a few thousand UML questions compared to mlllions on say Java. Hell won't break loose ;-) – qwerty_so Oct 23 '21 at 07:53
  • The ERD is wrong in the first place. It says that every book has a sequel and that every book is a sequel of another book. In other words, it says that every book is part of an infinite series of books. Yzarc, please describe how you would interpret the ERD and then we could find a proper UML representation for it. – www.admiraalit.nl Oct 25 '21 at 10:51

1 Answers1

2

In an ERD diagram with Chen’s notation:

  • the rectangles are entities, which in UML would be translated into classes;
  • the diamonds are relations between entities, which in UML would translate to associations;
  • (the elipses are attributed, which in UML would be represented either as properties or as association with another class);
  • the cardinalities would translate to multiplicities that you would show on the end of an association.

So in UML you’d have a book, and a reflexive association line labeled “sequel” and with a 1 near both ends. Much simpler that what you showed.

For more explanations about the mapping and the subtle differences, as well as transforming the one into the other, you may have a look at this other SO answer.

Finally, I am not sure that your 1:1 relation in Chen’s ERD notation is completely equivalent to your tabular notation: the association table that you use corresponds to a many to many association (since the same book can appear in several “records”). Additional code would be needed to retrict its use to 1:1. But btw I’m not sure that the sequel association would be a one to one either (i.e one book has only one other book as sequel and vice versa).

Christophe
  • 68,716
  • 7
  • 72
  • 138
  • Hmm. Actually I *would* model the Sequel in UML as he did, not as a simple association. When it comes to a DB you would have the need for a table which in UML is usually mapped to some class. – qwerty_so Oct 23 '21 at 07:56
  • Thinking of it, a sequel also will have some name to go with it (and depending on this and that probably more infos). – qwerty_so Oct 23 '21 at 09:38
  • @qwerty_so The misleading aspect in the original question is the name of the association: it's not the association that should be named "sequel", but the role of the association end. Because the sequel is -- as you rightly pointed out -- a full book/story/film. Now I agree with you in that the original ERD model does not explain how the sequel-book relates to the sequeled-book. It could explain how both relates. In this case, I'd use an association class. Nevertheless, this additional information seems not be in the original model and it's (surprisingly) 1 to 1, which makes AssoCl YAGNI – Christophe Oct 23 '21 at 17:37
  • Based on this definition: https://www.merriam-webster.com/dictionary/sequel I wonder if there is only one subsequent development for a book (i.e. a sequel for each main character as movie industry likes to do). Moreover a book could be the subsequent development of more than one original book (e.g. if several narrative universes are merged). Which leads me to question if 1:1 is really the right ERD cardinality, and if the UML association should not better have a *:* multiplicity. But up to the modeler to decide based on the requirements. – Christophe Oct 23 '21 at 17:42
  • 1
    Hehe. That's what UML is all about: start to think about things... – qwerty_so Oct 23 '21 at 20:08