Consider a situation where you have to map a complex class hierarchy with minimal database tables. Which inheritance strategy would you choose and what are its implications?

  • Joined Tables (JT): Each class in the hierarchy maps to its own database table, with a one-to-one relationship between the base class table and derived class tables.
  • Table per Concrete Type (TPC): Each class maps to its own database table, including inherited properties.
  • Table per Hierarchy (TPH): All properties from all classes are mapped to a single database table.
  • Table per Type (TPT): Each class in the hierarchy maps to its own database table.
Table per Hierarchy (TPH) strategy would be chosen. TPH reduces the number of database tables required by mapping all properties from all classes to a single database table. This strategy simplifies the database schema, making it easier to manage and understand. However, it may result in NULL values for properties specific to certain derived types, impacting database performance and storage efficiency.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *