Inheritance in O/R Mapping
|Object oriented applications usually have inheritance as an important part of their design, including in their domain objects. However, the corresponding data model has no built-in mechanism for specifying inheritance. Therefore, you must map your domain objects to your relational database intelligently.|
Domain objects in an application represent the core data that is used by the application and therefore these objects are usually persisted in some data source. If the data source is a relational DBMS, then domain objects have to be mapped to a relational model which looks different from an object model. Therefore, there are many things that you must keep in mind when mapping these domain objects to a relational database. This article focuses on mapping inheritance in your domain objects to your relational databases.
As you know, inheritance represents an "IS-A" relationship between two classes where the derived class inherits all the characteristics of the base class. Incidentally, there is no direct inheritance relationship defined in the relational model. Therefore, when you map inheritance from your object model to your data model, you have two different ways in which you can map inheritance to a relational database. They are:
1.Vertical inheritance mapping:
In this approach each class in the inheritance hierarchy maps to its own table in the database and all the tables in the database have a one-to-one relationship with each other.
2.Single-table inheritance mapping:
In this approach, all classes in the inheritance hierarchy map to the same single table in the database and this table contains columns for all the classes. It also contains a type column to indicate the type for each row.
In this article, we'll only discuss the one to one inheritance.
| read more | score:9634 | -iqbal khan, January 30, 2007|
Articles and website reviews are owned by their authors.
The rest is © 2000-2012, Ray Yeargin.
Abstract Art Gallery