Association, Composition and Aggregation

Kathiravan
1 min readAug 31, 2018

About basic object relationship

Association

  1. one to one
  2. one to many
  3. many to one
  4. many to many

Classification

  • Aggregation
  • Composition

Aggregation ( weak — both objects can live independent. Has a relationship)

  1. Student + Department
  2. Bank + Employee

Composition (Part of — object will have part of other object and dependent. Part of relationship)

  1. Book + Library
  2. Car + Engine

Aggregation vs Composition

  1. 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
  2. Type of Relationship: Aggregation relation is “has-a” and composition is “part-of” relation.
  3. Type of association: Composition is a strong Association whereas Aggregation is a weak Association.

--

--