Association, Composition and Aggregation
1 min readAug 31, 2018
About basic object relationship
Association
- one to one
- one to many
- many to one
- many to many
Classification
- Aggregation
- Composition
Aggregation ( weak — both objects can live independent. Has a relationship)
- Student + Department
- Bank + Employee
Composition (Part of — object will have part of other object and dependent. Part of relationship)
- Book + Library
- Car + Engine
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.