What are associations, links and aggregations?

Association is the relationship between two classes. When the association is between two classes, its called Binary Association.  When the association is between two instances of the same class, then its called  reflexive or unary association.
Example : Binary Association :  Employee works for Employee
                Unary Association: A Employee supervises Employees

For a given association between object A and object B,  there can be three possible categories (the following are called mutiplicity).

  1. One to One.  Exactly one instance of Class A is associated with exactly one instance of Class B and vice versa.  Example: A department has exactly one Head and One Head can lead only one departmet
  2. One to Many : One instance of Class A can have many instance of Class B.  From perspective of Class B, there can be only one Class A  Example : A department employees many Professors, but a professor works only for one department
  3. Many to Many :  For a given instance of Class A there can be many instance of Class B and From Class B perspective there can be many instances of Class A.  Example : A student enrolls in many courses and a course has many students

Link is the relationship between two objects. There are no multiplicity concepts in links.  Links always exists between two objects.

Example

Link :  Azagu works for Company-xxx

Aggregation : Aggregation is a special type of association or otherwise called as "Consists of " or " has a " or " is composed of " relationship.   Like an association, aggregation is used to reprsent relationship between two classes.  But with Aggregation we are representing to more number of relationship.  Example,  A car is composed of engine, gear, wheels etc.

Advertisements

Author: azagappan

Hi.. I am Azagu. I live in Chennai, Tamil Nadu, India. I am a .NET developer. You can reach me at azagappan at gmail.com

4 thoughts on “What are associations, links and aggregations?”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s