Its the relationship between two separate classes by their objects. It can be one to one, one to many, many to one and many to many. Composition and Aggregation are two forms of Association.
It represents a Has-A relation. Its a one way relationship which means that a departments can have multiple students but a student cant belong to multiple departments.
Also in aggregation both the entities can exists independently which means that they are not dependent on each other, ending one entity will not effect the other entity.
It is a relation in which both the entities are highly dependent on each other. It represents a part-of relationship. When there is a composition between two entities, the composed object cannot exist without the other entity.
Aggregation vs Composition
Dependency: Aggregation implies a relationship where the child can exist independently of the parent. For example, Bank and Employee, delete the Bank and the Employee still exist. whereas Composition implies a relationship where the child cannot exist independent of the parent. Example: Human and heart, heart don’t exist separate to a Human
Type of Relationship: Aggregation relation is “has-a” and composition is “part-of” relation.
Type of association: Composition is a strong Association whereas Aggregation is a weak Association.