Association, Composition and Aggregation

Kathiravan
Aug 31, 2018 · 1 min read

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.
Kathiravan
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade