Aggregation multiplicity UML

DKF picture DKF · Dec 18, 2012 · Viewed 9.1k times · Source

Me and my colleagues can't agree on a point. In UML, when an aggregation is made, does the diamond shape side have a multiplicity of 1 maximum, or can it be 0..* ? Or is it depending of a point of view ?
Thank you in advance !

Answer

Darren picture Darren · Sep 26, 2013

Firstly, you need to be specific about which 'diamond' you mean as a empty diamond in aggregation and a filled diamond is composition?

If you mean empty diamond then Icepack is correct, and you are confusing 2 separate things. Multiplicity is not related to Aggregation so a 'diamond shaped' aggregation indicator can have any multiplicity you like as they are unrelated.

If you mean filled diamond ie composition then the example someone has posted won't really help you as it's saying: "There are many departments but only 1 University (multiplicity)" and that "if all departments are deleted then University is also deleted (composition)".

I am struggling to think of a good example where composition end wouldn't be 1 only and as far as I can think it would never be 0..* as you can have a class which has to delete something which may not ever exist? I could however be 1..* ie many to many, for example Exam and Exam Questions.

The multiplicity may be 1..* to 1..* ie exam have 1 or more question and a question can reside in 1 or more exams. Filled diamond (composition) at Exam end would mean that if all questions were deleted then all exams would be deleted too