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
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
Copyright © 1997, 2004, Oracle. All rights reserved.