4.3.1.  Relationships Summary

[ fromfile: relationships.xml id: relationships-summary ]

You have seen three kinds of relationships:

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:

Figure 4.3 shows an example using containment and unidirectional relationships.

Figure 4.3.  Books and Pages

Books and Pages

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. [38]

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.



[38] You can see an example of this kind of setup in the online version of this book.