Skip Headers

# Single Table Inheritance

Previous

Next

In this example, you store classes with multiple levels of inheritance in a single table to optimize database access speeds.

The entire inheritance hierarchy shown in Figure: Example Inheritance Hierarchy can share the same table, as in Figure: Inheritance Using a Superclass Table with Optional Fields. 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.

As Figure: Inheritance Using a Superclass Table with Optional Fields shows, this approach uses a class indicator field. For more information, see "Specifying a Class Indicator".

Inheritance Using a Superclass Table with Optional Fields

Description of "Inheritance Using a Superclass Table with Optional Fields"