Associations
The structural links between classes - roles, multiplicities, navigability, and how to read them without ambiguity.
Structural, not transient
An association is a structural relationship between two classes: instances on one side hold lasting references to instances on the other. If a Member keeps a list of its Loan objects for as long as both exist, that is an association. If a ReceiptPrinter receives a Loan as a method parameter, uses it, and forgets it, that is a dependency — a weaker, transient relationship drawn with a dashed arrow.
The distinction pays off when you read a class diagram: solid association lines describe the object graph that exists at runtime — fields, collections, and eventually foreign keys — while dashed dependency lines only describe who calls whom. If you want to know what state a system holds, follow the associations.
class Member {
loans: Loan[] = []; // association: a lasting reference
// ...
}
class ReceiptPrinter {
print(loan: Loan): void { // dependency: transient use
// format and print, then forget the loan
}
}Aggregation and composition are associations with extra claims about ownership and lifetime; everything on this page applies to them too. See aggregation and composition for what those decorations add.
Multiplicity
A multiplicity is written at each end of the line and constrains how many instances may sit at that end.
| Notation | Meaning | Example reading |
|---|---|---|
1 | Exactly one | A Loan belongs to exactly one Member |
0..1 | Optional, at most one | A Room has at most one current Booking |
* | Zero or more | A Member has zero or more Loans |
1..* | At least one | An Order contains at least one OrderLine |
2..5 | Bounded range | A ReviewPanel has between two and five Reviewers |
The reading rule: stand at one instance of the class at the far end and ask how many instances it can be linked to at the near end — the answer is the multiplicity written next to the class you are counting. For Member 1 --- * Loan:
- Reading toward Loan: one Member has 0..* Loans.
- Reading toward Member: one Loan belongs to exactly 1 Member.
Role names
Each end of an association can carry a role name: the name by which the opposite class knows the instances at that end. Role names usually map one-to-one onto field names in code, which makes them more useful than association names for anything you intend to implement.
They are indispensable when the same pair of classes is connected more than once. A Flight relates to Airport twice — once as origin, once as destination. An association name like "flies between" cannot tell the two ends apart; role names can.
class Flight {
Airport origin; // role name at one Airport end
Airport destination; // a second association to the same class
}Heuristic, not rule: name the association only when the verb carries domain meaning ("employs", "guarantees"). Otherwise prefer role names, or leave the line bare.
Navigability
An open arrowhead on an end means instances at the opposite end can reach it efficiently — in code, that a field exists in that direction. An arrow pointing from Order to Customer says an Order knows its Customer, while a Customer has no direct path back to its Orders.
Formal UML distinguishes navigable ends (arrowhead), explicitly non-navigable ends (a small x), and unspecified ends (nothing). The common industry convention in analysis models is to leave every end unadorned and treat associations as conceptually bidirectional, deferring the decision to design — where it becomes a real cost: a bidirectional association means two references that must be kept consistent on every update. Preferring a single direction unless traversal both ways is genuinely needed is sound design advice, not a UML requirement.
Association or attribute?
Formally, attributes and association ends are both properties of a class, and UML treats them as nearly interchangeable. The useful convention separates them by what the target is:
| Question | Association | Attribute |
|---|---|---|
| Target | A class you model in the diagram (Member, Room) | A value type (String, Money, LocalDate) |
| Identity | Target instances have identity and a lifecycle | Values are compared by content and freely copied |
| Diagram effect | Exposes the structure of the object graph | Keeps the class box compact |
Drawing an association to String adds a box and a line that tell the reader nothing. Conversely, burying member: Member in the attribute compartment of Loan hides the most important structural fact in the model. The split follows from what objects and values are — see objects and classes.
Reach for it
- The target is a domain class with its own box in the diagram
- You need multiplicity, role names, or navigability on the link
- The reference is lasting and shapes the runtime object graph
Avoid it
- The target is a value type such as String or Money
- The reference exists only for the duration of one method call
- The detail is an implementation field with no domain meaning
Common mistakes
Multiplicities on the wrong end. The classic. Modelers write * next to Member because "a member has many loans" — but the * belongs next to Loan, the class being counted. The reading rule above catches this every time.
Naming every association. "Member has Loan", "Order has OrderLine" — the name restates the line. Redundant names train readers to skip names entirely, which makes the meaningful ones ("supervises", "reserves") invisible when they matter.
Modeling every field as an association. A diagram where email, name, and createdAt each get their own box is wallpaper, not a model. Reserve association lines for links between domain classes; the same discipline that keeps ER models readable applies here.
Practice
Model a hotel booking domain with Guest, Booking, and Room. Draw the associations with multiplicities and role names, deciding as you go: can a Booking exist without a Guest? Can one Booking span several Rooms? Can a Room have overlapping Bookings? Verify each multiplicity by reading it aloud in both directions — every sentence must be true in the domain. Finally, assume the only feature is "show a guest their bookings" and add navigability arrows for exactly that; note which references you were able to drop.