Sometimes a class consists of a number of component classes. This is a special type of relationship called aggregation. The components and the class they constitute are in a part-whole association.
Aggregation is represented as a hierarchy
with the "whole" class at the top, and the component below. A line joins a whole
to a component with an open diamond on the line near the whole.
Let's take
a look at the
parts consisting a TV set. Every TV has a TV box, screen, speaker(s), resistors, capatitors,
transistors, ICs... and possibly a remote control. Remote control can have these parts:
resistors, capatitors, transistors, ICs, battery, keyboard and remote lights.
An aggregation association in the TV Set system |
Sometimes the set of possible components in an aggregation falls into an OR relationship. To model this, you would use a constraint - the word OR within braces on a dotted line that connects the two part-whole lines.
A composite is a strong type of
aggregation. Each component in a composite can belong to just one whole. The symbol for a
composite is the same as the symbol for an aggregation except the diamond is filled.
If you examine the
human's outside you'll find out that every person has: head, body, arms and legs. This is
shown on this picture.
A composite association. In this association each component belongs to exactly one whole. |
An
aggregation specifies a part-whole association. A "whole" class is made up of
component classes. A composite is a strong form of aggregation, and a component in a
composite can be part of only one whole. Aggregations and composites are represented as
lines joining the whole and the component with open and filled diamond, respectively, on
the whole side.