Pattern: One Inheritance Path One Table


The pattern demonstrates a way to map all attributes occurring in an inheritance path to a single database table.


How do you map an inheritance hierarchy of classes to database tables?


The forces are identical to those discussed with the One Inheritance Tree One Table pattern.


Map the attributes of each class to a separate table. To a classes’ table add the attributes of all classes the class inherits from.


Example Resolved

Mapping our running example to tables results in five tables - one for each class. An instance of a SalariedEmployee is represented in one of these five tables. The SalariedEmployee is mapped as follows:


         Database load on root tables: There are no bottlenecks in tables near to the root of the inheritance hierarchy. Accessing an object exactly locks one table.


Related Patterns

See also Representing Inheritance in a Relational Database [Bro+96]. See the same thing as Class Inheritance Table at Martin Fowlers site.