1

Some books describe it as a 1:m association between classes A and B with an implied 0..1 label at the diamond end, while others see it as a 1:1, 1:m or m:n whole-part association. Which one is correct?

Thanks!

newthau
  • 21
  • 2
  • 1
    Welcome to `Stack Overflow`, It is preferred if you can post separate questions instead of combining your questions into one. That way, it helps the people answering your question and also others hunting for at least one of your questions. Thanks! – Hille Jan 08 '18 at 13:08
  • 1
    Thanks, i'll edit this question to retain only the first point and post a new one for 2 and 3. – newthau Jan 08 '18 at 13:23

1 Answers1

0

All versions are correct, they key of aggregation is not cardinality (1:1, 1:m or m:n) it can has anyone of these you mentioned.

The key is that even when e.g. an instance of B is in an instance of A, if you destroys A, B remains.

e.g.: A company has clients and clients will still existing when company disappears (aggregation) but employees won't to be employees when company disappears (composition).

Not my best analogy but representative enough I guess.

It's like in databases and for me this view is more clear, a table with a foreign key will be aggregation and relational 3rd table is composition.

xpeiro
  • 733
  • 5
  • 21
  • Useful post https://stackoverflow.com/questions/885937/what-is-the-difference-between-association-aggregation-and-composition – xpeiro Jan 10 '18 at 14:44