Composition and aggregation are two types of association which is used to represent relationships between two classes.
In Aggregation , parent and child entity maintain Has-A relationship but both can also exist independently. We can use parent and child entity independently. Any modification in the parent entity will not impact the child entity or vice versa. In the UML diagram, aggregation is denoted by an empty diamond, which shows their obvious difference in terms of strength of the relationship.
In Composition, parent owns child entity so child entity can’t exist without parent entity. We can’t directly or independently access child entity. In the UML diagram, composition is denoted by a filled diamond.
Composition(mixture) is a way to wrap simple objects or data types into a single unit
Aggregation(collection) differs from ordinary composition in that it does not imply ownership
In composition , parent entity owns child entity.
In Aggregation , parent Has-A relationship with child entity
It is denoted by a filled diamond.
It is denoted by an empty diamond.
Child doesn’t have their own life time
Child can have their own life time
It is a strong association
It is a weak association