Link and Association Concepts

02 Multiplicity

Multiplicity states how many objects on one end of an association can be linked to a single object on the other end. It's written as a number or a range at each end of the association line — the most common shorthand, an asterisk, simply means "zero or more."

Common student mix-up

Multiplicity is not the same as cardinality. Multiplicity is the rule — the constraint written on the diagram. Cardinality is the actual count in a particular case at a particular moment.

03 Association End Names

Just as an association itself can have a name, each end of an association can too. An association end name describes the role a class plays from the other side's point of view — usually a noun, not a verb.

Person
WorksFor
employee *employer 0..1
Company

Here, a Person plays the role of employee with respect to a company, and a Company plays the role of employer with respect to a person. These end names matter most in two situations that come up constantly in student projects:

04 Ordering

By default, the objects on a "many" end of an association have no inherent order — think of them as an unordered set. Sometimes, though, order genuinely matters to the problem. A stack of overlapping windows on a screen, for example, needs to remember which window is on top.

Screen
VisibleOn
1{ordered} *
Window

Writing {ordered} next to an association end tells the reader — and eventually, whoever implements the model — that sequence is a meaningful part of this relationship

05 Bags and Sequences

Normally, an association allows at most one link between any given pair of objects. To allow the same pair of objects to be linked more than once, mark the association end with {bag} or {sequence}.

{bag}

An unordered collection that allows duplicates. Multiple links between the same pair of objects are permitted, but no particular order among them is implied.

{sequence}

An ordered collection that allows duplicates — effectively {ordered} plus repetition allowed. A flight itinerary that revisits the same airport twice needs a sequence, not just an ordered set.

AnnotationOrdered?Duplicates allowed?
(none)NoNo
{ordered}YesNo
{bag}NoYes
{sequence}YesYes

06 Association Classes

Sometimes a piece of data doesn't belong to either object in a relationship — it belongs to the link itself. An association class lets an association carry its own attributes and operations, drawn as a class box attached to the association line by a dashed line.

File
AccessibleBy
**
User
AccessibleBy
accessPermission : string

07 Qualified Associations

A qualified association uses an extra attribute . that describes the association. It is the Attributr which is used toconnect two objects

Bank
Services
1accountNumber0..1
Account

Without a qualifier, a bank services "many" accounts, and finding one specific account means searching the whole set. With accountNumber as a qualifier, the model states directly: given a bank and an account number, there's at most one matching account