Name
Table Inheritance Pattern
Goal
Provide a simple mapping between a class hierarchy and a set of database tables.
Participants
- Domain object model
Provides an object representation of the data a system must deal with.
- Database schema
Provides a method to store and query against the data in the domain object model.
Interactions
- Concrete table inheritance
Each concrete class in the domain object model has a corresponding table in the underlying database schema. When the object model is persisted to the database, each object is written to a row in the corresponding table.
- Class table inheritance
Each class in the domain object model, whether abstract or concrete, has a corresponding table containing the data items defined in that class. Tables associated with a subclass are linked within the database, via primary key relations, with the table associated with their superclass.
Get J2EE Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.