Chapter 8 O/R Mapping Modeling


Applying table per class hierarchy strategy

The whole class hierarchy should be mapped to one table. There should be one discriminator column defined to distinguish instances of difference classes in the hierarchy. The column can have character based type or integer type.



Steps To apply table per class hierarchy strategy:

  1. Define class mappings for each class in the hierarchy.

    All the classes have the same primary table. They can also be mapped to other secondary tables.
  2. 2 Define identifier mapping in the root class.
  3. 3 Define attribute mappings or association mappings for each class.
  4. 4 Define discriminator column in the root class.

For each class hierarchy, a discriminator is needed to distinguish between different class instances. You have to select one of the attributes in the root class, in the Specifying Attribute list of the property sheet of one of the children inheritance links of the root class. The attribute will be transformed into a discriminator column. In the following example, we define one extra attribute shapeType in Shape and select it as discriminator attribute:


 


Copyright (C) 2006. Sybase Inc. All rights reserved.