Skip to content

Inheritance patterns: Single Table Inheritance

G4br13l3 edited this page Sep 3, 2015 · 16 revisions

Single Table Inheritance

Single Table strategy is the simplest and typically the best performing and best solution. By this inheritance strategy, we can map the whole hierarchy by single table only. The table will have a column for every attribute of every class in the hierarchy and an extra column (also known as discriminator column) is created in the table to identify the class.

Example

Now suppose you want to map the whole hierarchy given below on the left into one table of the database. The table structure for this hierarchy is that shown on the right.