Please note: this project is inactive since early 2006

 
2.6.4 How to model inheritance

When you have inheritance hierarchies in your object model, they should be correctly modeled. We present below the three possible ways to map an inheritance hierarchy to the relational world, then we'll see how to model these so that they can be taken into account by the framework.

There are three typical ways to model an inheritance hierarchy into an RDBMS schema-we do not take into account special RDBMS functionalities, just raw relational/SQL possibilities. Among these three, only one, Horizontal Mapping, is supported by the framework so far.

A more complete discussion, along with figures and examples, can be found at http://www.objectmatter.com/,

Horizontal Mapping
In this configuration, each entity stores all instance data in a single table, whatever the inheritance hierarchy can be. That is to say that, if class A2 inherits from A1, they each have their own table (respectively, table A2 and table A1) which stores the instance data. This configuration does not put any information about the inheritance schema into the relational database, rather it lets the runtime do the job and take the inheritance into account.

Vertical Mapping
(not supported yet) In this configuration, the root entity has its own table. A sub-entity then defines a table whose columns corresponds to the set of attributes that are not inherited; inherited informations, such as attributes or foreign keys for inherited relationships, are stored in the root entity's table, and are retrieved using a SQL join between the two tables.

Filtered Mapping or ''Single table''
(not supported yet) In this configuration, a root entity and all its sub-entities store their data in the same table. This table hence defines the whole set of possible attributes. To be able to distinguish rows corresponding to A1 instances from rows corresponding to A2 instances, each entity defines a qualifier. For example, instances of A1 will have a type code of 1 stored in the table's column 'TYPE', while instances of class A2 will map to rows whose type is 2.

Note: Remember the fact that the model, build in the ZModelizationTool or directly in an xml-model and used by the framework's core, is not a model per se but rather a mapping of an object model to a relational model. As a consequence, you should not be surprised that, whatever mapping you choose to model a specific inheritance hierarchy, each entity and all sub-entities must define and describe all entity attributes and relationships-inherited or not.


Subsections
Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted by:SourceForge.net Logo