info@tutsfinder.in



Association

It represents a relationship between two or more objects where all objects have their own life cycle and there is no owner that means no one is depend on another.

Association can be one to one, one to many, many to one, many to many.

The objects that are part of association can be created and destroyed independently.

For Example: Relationship between doctor and patient. A doctor can be associated with multiple patients and at the same time, patient can visit multiple doctors for treatment. In this, each object doctor and patient has its own life cycle.

There are two forms of association:

1. Aggregation

2. Composition



Association


Aggregation

It represents Has-A relationship.

Aggregation is a kind of association where both entities survives independently which means ending one entity will not affect the other entity.

It is a unidirectional association i.e. one way relationship.

For Example: Here two entities Department and Teacher. A Teacher may belong to multiple Departments. Hence Teacher is a part of multiple departments. But if we delete a department, Teacher entity will not destroy.



Composition

It represents a one to many relationship.

It is restricted form of aggregation where entities are highly dependent on each other. On entity cannot be exist without other.

It is a strong relationship.

For Example: College consists of several departments whenever college entity destroys automatically all the department entities will be destroyed that is without existing college entity there is no chance of existing dependent entity.