Example & Tutorial understanding programming in easy ways.

What are the different approaches to represent an inheritance hierarchy?

There are some different approaches to represent an inheritance hierarchy those are as below:

Table per concrete class.
Table per class hierarchy.
Table per subclass.


Table per Hierarchy (TPH):
This approach suggests one table for entire class inheritance hierarchy. Table includes discriminator column which distinguish between inheritance classes.

Table per Type (TPT): This approach suggests one table for each of the classes thus each class will have a persistence table.

Table per Concrete class (TPC): This approach suggests one table for one concrete class, but not for the abstract class. So if you inherit the abstract class in multiple concrete classes then the properties of the abstract class will be part of each table of concrete class.

Read More →