# UML Composition parent multiplicity

The Wikipedia article on the Composite Design Pattern includes the following diagram:

As you see, there is an association relationship which is `child 0..* – 1 parent`.

However, given that:

1. a `Composite` class is a `Component` as well, and
2. every `Component` has a `parent` (a `Composite`)...

Doesn't this force an infinite tree of child-parent relationships?

That would happen because there can't be a `root` element of the arboreal structure if every `Component` needs a `parent`. As I see it, the `parent` should instead have a `0..1` multiplicity.

Am I missing something?

• Technically you are correct. However, if the diagram is just used to explain the concept, one could probably condone the fact that the multiplicity is only "mostly" correct, It depends heavily on who your audience is. Commented Jan 8, 2022 at 22:02

You are completely right in your claim.

In the original GoF the shared aggregation is without any indication of multiplicity on the parent side (Caution: GoF used the OMT notation, one of the three ancestors of UML, but in this specific case it's the same meaning than in UML). This was left unspecified on purpose:

• GoF mentions the possibility of components shared between several composites: so a child could have several parents.
• In many cases however, this is not relevant and an upper bound of 1 could make sense.
• Of course, some root components would have no parents at all.

In UML the multiplicity `1` means `1..1`, so always 1. This is wrong as you pointed out. 0..1 would be correct, although leaving it unspecified for allowing the shared component, would be best.

Additional remarks: The wikipedia article would require some cleaning: there are 3 very redundant UML diagrams that have it right on the side of the aggregation, but require at least 1 child, which is also an infinite recursion. And you have the fourth wrong diagram that you asked about. The problem is that it becomes a source of errors: a google image search, shows on the 30 first pictures that 14 (almost 50%) repeat the same error!

• Great answer! I believe it could be a good idea, as well, to move this discussion to the original Wikipedia article. Thanks a lot for such a detailed explanation! Commented Jan 9, 2022 at 15:20