How to Represent Relationships in Tables - UML

The code in the prior section relies on a MANU_OID foreign key in the PRODUCTJSPEC table to link to a record in the MANUFACTURER table. This highlights the question: How are object relationships represented in the relational model?

The answer is given in the Representing Object Relationships as Tables pattern {BW96], which proposes the following:

  1. one - to - one associations
    • Place an OID foreign key in one or both tables representing the objects in relationship.
    • Or, create an associative table that records the OIDs of each object in relationship.
  2. one - to - many associations, such as a collection
    • Create an associative table that records the OIDs of each object in relationship.
  3. many - to - manyassociations
    • Create an associative table that records the OIDs of each object in relationship.

PersistentObject Superclass and Separation of Concerns

A common partial design solution to providing persistence for objects is to create an abstract technical services superclass PersistentObject that all persistence objects inherit from. Such a class usually defines attributes for persistence, such as a uniojue OID, and methods for saving to a database.

This is not wrong, but it suffers from the weakness of coupling the class to the PersistentObject class - domain classes end up extending a technical services class.

Figure 37.17 Problems with a PersistentObject superclass

This design does not illustrate a clear separation of concerns. Rather, technical services concerns are mixed with domain layer business logic concerns by virtue of this extension.

On the other hand, "separation of concerns" is not an absolute virtue that must be followed at all costs. As discussed in the Protected Variations introduction, designers need to pick their battles at the truly likely points of expensive instability. If in a particular application making the classes extend from PersistentObject leads to a neat and easy solution and does not create longer - term design or maintenance problems, why not? The answer lies in understanding the evolution of the requirements and design for the application. It is also influenced by the language: Those with single inheritance (such as Java) have had their single precious superclass consumed.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

UML Topics