Define the Notation for modeling Associations, including Naming, Roles, Multiplicity, and Constraints
Notation for modeling Associations
Naming, Roles, Multiplicity, and Constraints
A class can communicate only with another class it knows about, for instance, a class with which it is associated.
To associate classes, use a line between two classes adorned with some qualifying elements.
Remember how parts of speech map to elements in the models? Every association needs a name, an active verb that describes the relationship of one class to another class, such as "owns" or "opens."
Multiplicity: A number of objects of each class may be associated. For example, a customer may open many accounts, and an order may include many items. The number of participating objects is called the multiplicity, and it must be set for each end of the association. The notation for multiplicity is:
Asterisk (*) when used alone means zero or more, no lower or upper limit
Asterisk (*) when used in a range (1..*) means no upper limit
Values separated by two periods (..) means a range.
Values separated by commas means an enumerated list of values.
When an association name is difficult to define, roles provide an alternative. A role name such as "supervisor" may be placed on one or both ends of the association. Finally, you can add constraints using the standard notation. Place the constraint on the end of the association that is being constrained.
In this example, you see two classes, Customer and Order. A customer may place zero or more orders, but an order cannot exist unless a customer places it. The customers placing the orders are preferred customers only, and orders they place are priority orders.
The role names clarify the interpretation of the association between the two classes.