Sunday, 11 August 2013

Class Table Inheritance Design Pattern

Master Enterprise Architecture Patterns!

Subscribe to Ram N Java for in-depth, easy-to-follow database and software design pattern tutorials!

Subscribe on YouTube

What is the Class Table Inheritance Pattern?

The Class Table Inheritance pattern is an Object-Relational Structural Pattern used in Enterprise Application Architecture.

Since relational databases do not natively support inheritance, this pattern represents an inheritance hierarchy of classes by mapping one database table for each class in the hierarchy.

How Class Table Inheritance Works

Each class in your domain model maps directly to its own database table containing only the fields unique to that class:

  • Player Class (Superclass): Maps to the players table (stores name).
  • Footballer Class: Maps to the footballers table (stores club).
  • Cricketer Class: Maps to the cricketers table (stores batting_average).
  • Bowler Class: Maps to the bowlers table (stores bowling_average).

Linking Rows Across Tables

To link corresponding records across parent and child tables, a common Primary Key (foreign key pointing to parent table) is used:

  • Saving Data: An instance of a child class requires inserting rows into both the parent table and the child table.
  • Reading Data: Querying full object details requires joining the parent and child tables using their shared primary key.

Recommended Tutorials from Ram N Java


Click here to watch in Youtube : https://www.youtube.com/watch?v=UatcHToJF00

Click the below Image to Enlarge
Class Table Inheritance Design Pattern















See also:

  • All Design Patterns Links
  • No comments:

    Post a Comment

    Tutorials