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.
- Unidirectional Association.
- Bidirectional Association.
- Aggregation.
- Composition.
- Asymmetric Reflexive Associations.
- Symmetric Reflexive Associations.
Unidirectional Association.
In unidirectional association, two objects are related but only one object know about the relation.
Bidirectional Association.
In bidirectional association, two objects are related and both objects know about the relation.
Aggregation.
Aggregation is another variant of has-a relationship. Association that represents a part-whole or part-of relationship.
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.
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.
Symmetric Reflexive Associations.
In symmetric reflexive associations the roles at either end are identical. Category-Sub category relationship is good example.
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 |
Pingback: UML — Class Diagram — Generalization & Realization
Pingback: UML — Class Diagram — Dependency/Uses