Association, Aggregation and Composition
What is Association, Aggregation and Composition?
These are different terms which represents relationships among objects.
Association(i.e. a group of people organized for a joint purpose):
- It is a relationship among the objects.
- It means a relationship between two or more objects which are linked to each other but each object has there own life cycle and there is no owner.
Example:
Let's take an example of the relationship between a Teacher and a Student.
- Multiple student can be associated with a single teacher.
- A single student can be associated with multiple teacher.
Note: Association is represented by single straight line, as shown in the above image.
- Multiple student can be associated with a single teacher.
- A single student can be associated with multiple teacher.
Aggregation(i.e. the collection of related items of content so that they can be displayed or linked to):
- It is a special type of Association, where all object have their own lifecycle but there is ownership.
Example:
Let's take an example of the relationship between Department and Teacher.
- A Teacher may belong to multiple Departments. i.e., teacher is a part of multiple departments.
- A department can have multiple teachers also.
Note: Aggregation is represented by diamond straight line, as shown in the above image.
Composition(i.e. the nature of something's ingredients or constituents):
- It is specialized form of Aggregation. i.e. It is a strong type of Aggregation.
- In this relationship child object does not have a lifecycle without parent object.
- If parent object is deleted then child object is also deleted.
Example:
Let's take an example between Company and Company Location.
- Here Company Location is completely dependent on Company object.
If Company object is deleted then Company Location object is also deleted. So, child object is dependent on parent object.
Note: Composition is represented by solid diamond straight line, as shown in the above image.
Conclusion:
So if we closely observe the concepts of Association, Aggregation and Composition, we can say Aggregation and Composition are a special type of Association. Composition is again a special type of Aggregation. So in other words we can say that
- Composition is a subset of Association and Aggregation.
- Aggregation is a subset of Association.





Comments
Post a Comment