UML Association, Aggregation, Composition
UML Association, Aggregation, Composition
• As you can see from the example given below, the composition
association relationship connects the Person class with Brain class,
Heart class, and Legs class. If the person is destroyed, the brain,
heart, and legs will also get discarded.
Association vs. Aggregation vs. Compositi
Association Aggregation Composition
Association relationship is represented using an arrow. Aggregation relationship is represented by a straight line with an empty diamond at one end. The composition relationship is represented by a straight line with a black diamond at one end.
In UML, it can exist between two or more classes. It is a part of the association relationship. It is a part of the aggregation relationship.
It incorporates one-to-one, one-to-many, many-to-one, and many-to-many association between It exhibits a kind of weak relationship. It exhibits a strong type of relationship.
the classes.
It can associate one more objects together. In an aggregation relationship, the associated objects exist independently within the scope of In a composition relationship, the associated objects cannot exist independently within the
the system. scope of the system.
In this, objects are linked together. In this, the linked objects are independent of each other. Here the linked objects are dependent on each other.
It may or may not affect the other associated element if one element is deleted. Deleting one element in the aggregation relationship does not affect other associated It affects the other element if one of its associated element is deleted.
elements.
Example: A tutor can associate with multiple students, or one student can associate with Example: A car needs a wheel for its proper functioning, but it may not require the same wheel. Example: If a file is placed in a folder and that is folder is deleted. The file residing inside that
multiple teachers. It may function with another wheel as well. folder will also get deleted at the time of folder deletion.