Supporting Inheritance Using One Table

Store classes with multiple levels of inheritance in a single table to optimize database access speeds.

The following diagram illustrates the Vehicle object model.

Figure 4-19 Supporting Inheritance Using One Table

This figure shows a sample Java inheritance hierarchy using one table.

The entire inheritance hierarchy can share the same table, as in Figure 4-20. The FueledVehicle and NonFueledVehicle subclasses can share the same table even though FueledVehicle has some attributes that NonFueledVehicle does not. The NonFueledVehicle instances waste database resources because the database must still allocate space for the unused portion of its row. However, this approach saves on accessing time because there is no need to join to another table to get the additional FueledVehicle information.

Figure 4-20 Inheritance Using a Superclass Table with Optional Fields

This figure shows a sample inheritance using a superclass table with optional fields.


Related Topics

About TopLink Descriptors

Working with Descriptors
Working with Inheritance
Working with Descriptor Properties
Working with Advanced Properties

Using Inheritance with EJBs
Mapping Inherited Attributes in One Descriptor
Supporting Inheritance Using Multiple Tables

 

Copyright © 1997, 2004, Oracle. All rights reserved.