Skip to content
On this page

Association Relationships

Association is used to model objects that contain other objects. That is when a class holds a data field reference to another class. For example, Course has a (field of type) Instructor: Association represents a "has-a" relationship. It is represented by a (solid) line between two classes.

We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association.

uml diagram

The above example indicates that a Course has one Instructor.

uml diagram

The above example indicates that an Instructor is associated with (teaches) one or more Course.

We can indicate the role of an object in an association using role names.

uml diagram

We can also name the association.

uml diagram

We can specify more than one association on a pair of classes.

uml diagram

We can constrain the association relationship by defining the navigability of the association.

uml diagram

Here, a Router object requests services from a DomainNameServer object by sending messages to (invoking the operations of) the server. The direction of the association indicates that the server does not know the Router.

A class can have a self-association.

uml diagram

Finally, there are special associations called aggregations and compositions.

Aggregation

An aggregation specifies a whole-part relationship between an aggregate (a whole) and a constituent part, where the part can exist independently from the aggregate. Aggregations are denoted by a hollow-diamond adornment on the association.

uml diagram

Composition

A composition indicates strong ownership and a coincident lifetime of parts by the whole (i.e., they live and die as a whole). Compositions are denoted by a filled-diamond adornment on the association.

uml diagram

Released under the MIT License.