For subclasses that require additional attributes, use multiple tables instead of a single superclass table. This optimizes storage space because there are no unused fields in the database. However, this may affect performance because TopLink must read from more than one table before it can instantiate the object. TopLink first looks at the class indicator field to determine the class of object to create, then uses the descriptor for that class to read from the subclass tables.
Figure 4-21 illustrates the TopLink implementation of the FUELEDVHCL
, CAR
, and BICYCLE
tables. All objects are stored in the VEHICLE
table. FueledVehicle
, Car
, and Bicycle
information are also stored in the secondary table.
Figure 4-21 Inheritance Using Separate Tables for Each Subclass
NonFueledVehicle
does not hold any attributes or relationships, it does not need a secondary table. For performance considerations, this design is inefficient because it requires multiple table fetching.
Copyright © 1997, 2004, Oracle. All rights reserved.