[ fromfile: relationships.xml id: relationships-summary ]
You have seen three kinds of relationships:
Association (purely for navigation)
Aggregation (containment without management)
Composition (containment with management)
A composite relationship is a strong one, which also describes parent-child and (managed) container-contained relationships. In addition, each relationship can have the following properties:
Cardinality – Can be one-to-one, one-to-many, or many-to-many. Often, a number (1, 1..5, *) next to the end of the line segment specifies this.
Navigability – Can be unidirectional or bidirectional. Unidirectional relationships may have arrows instead of diamonds on the line segments between classes.
Figure 4.3 shows an example using containment and unidirectional relationships.
In this diagram, a Book
is a (managed) container of Page
pointers but, additionally, the pages have their own navigation
relationships. Perhaps a reader (or browser) would benefit from direct navigation links to neighboring pages
and to the table of contents. Each of these is a unidirectional relationship, so you could show three
self-pointing arrows and the diagram would not be incorrect.
For the m_pages
relationship, there is no reverse relationship
shown, so this could describe a unidirectional or a bidirectional containment relationship. If there is need
for the Page
to navigate to its containing Book
object, you should make the directionality more clear in the diagram. You could do this by labeling the
other end of the relationship, and/or by adding an m_Book
attribute to the
Page
class.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |