UML – Class Diagram – Association.

In this post we will talk about representing different kinds of association in Unified Modelling Language (UML). The term association is used to refer a specific types of logical connections found on class. Association is considered as relationship on instance level. Please refer this post for inheritance/generalization/realization.

Types of associations.

In general, there are five kinds of associations.

  1. Unidirectional Association.
  2. Bidirectional Association.
  3. Aggregation.
  4. Composition.
  5. Asymmetric Reflexive Associations.
  6. Symmetric Reflexive Associations.

Unidirectional Association.

In unidirectional association, two objects are related but only one object know about the relation.
UML Undirectional simple association

Bidirectional Association.

In bidirectional association, two objects are related and both objects know about the relation.

uml bidirectional simple association

Aggregation.

Aggregation is another variant of has-a relationship. Association that represents a part-whole or part-of relationship.
UML aggregation

In the above example steering is part of car. At the same time steering has it’s own existence.

Composition.

Composition is special type of association. In this kind of association the whole virtually own the part. The part doesn’t exist without the whole.
UML composition
In the above example menu is part of window. Menu exist only if windows exist. Once the window is closed the menu also get destructed.

Asymmetric Reflexive Associations.

Reflexive association is an association from an object to itself. In asymmetric association, ends of the association are semantically different from each other. In asymmetric reflexive association the roles at either end are different.
UML Asymmetric Reflexive Associations

Symmetric Reflexive Associations.

In symmetric reflexive associations the roles at either end are identical. Category-Sub category relationship is good example.
UML Symmetric Reflexive Associations

Representing multiplicity.

Information placed at each end of an association indicating how many instances of one class can be related to instances of the other class

Multiplicity Cardinality
1 exactly one
1..2 one or two
1..* minimum one; no maximum
1..4 minimum one; maximum four
0..* zero or many

UML association multiplicity

Further Reading.

UML org.
UML Distilled.

2 thoughts on “UML – Class Diagram – Association.