When classes are connected together conceptually, that connection is called an association.
You
visualize the association as a line connecting the two classes, with the name of the
association just above the line.
Association may be more complex than just one class connected to another. Several
classes can connect to one class.
Sometimes an association between two classes has to follow a rule. You indicate that rule
by putting a constraint near the association line.
You
visualize association class the same way you show a regular class, and you use dotted line
to connect it to the association line.
Multiplicity is a special type of
association which shows the number of objects from one class that relate with a number of
objects in an associated class.
One class can be relate to another in a
| one-to-one | |
| one-to-many | |
| one-to-one or more | |
| one-to-zero or one | |
| one-to-a bounded interval (one-to-two through twenty) | |
| one-to-exactly n | |
| one-to-a set of choices (one-to-five or eight) |
The UML uses an asterisk (*) to represent more and to represent many.
Sometimes, a class is in association with itself. This can happen when a class has objects that can play a variety of roles. These associations are called reflexive associations.
Without
relationships, a class model would be a list of rectangles that represent a vocabulary of
system. Relationships show how the terms in the vocabulary connect with one another to
provide a picture of the slice of the world you're modeling. The association is the
fundamental conceptual connection between classes. Each class in an association plays a
role, and multiplicity specifies how many objects in one class relate to one object in the
associated class. Many types of associates are possible.