Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Single Table Inheritance
Technique to model object relationships onto relational databases

Single table inheritance is a way to emulate object-oriented inheritance in a relational database. When mapping from a database table to an object in an object-oriented language, a field in the database identifies what class in the hierarchy the object belongs to. All fields of all the classes are stored in the same table, hence the name "Single Table Inheritance". In Ruby on Rails the field in the table called 'type' identifies the name of the class. In Hibernate (Java) and Entity Framework this pattern is called Table-Per-Class-Hierarchy and Table-Per-Hierarchy (TPH) respectively., and the column containing the class name is called the Discriminator column.

We don't have any images related to Single Table Inheritance yet.
We don't have any YouTube videos related to Single Table Inheritance yet.
We don't have any PDF documents related to Single Table Inheritance yet.
We don't have any Books related to Single Table Inheritance yet.
We don't have any archived web articles related to Single Table Inheritance yet.

Example

Blogs
BlogIdDiscriminatorUrlRssUrl
1Bloghttps://blogs.example.com/petsNULL
2RssBloghttps://blogs.example.com/carshttps://blogs.example.com/cars.rss

The table have the Url which is used by all blogs but only blogs of type RssBlog have a value assigned in the RssUrl column, other rows have NULL.

See also

References

  1. Fowler, Martin (2003). Patterns of Enterprise Application Architecture. The Addison-Wesley Signature Series. Contributions by Dave Rice, Matthew Foemmel, Edward Hieatt, Robert Mee, and Randy Stafford. Addison-Wesley. p. 278. ISBN 0-321-12742-0. 0-321-12742-0

  2. "Tutorial: Implement Inheritance with EF in an ASP.NET MVC 5 app". January 21, 2019. Retrieved November 3, 2015. https://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/implementing-inheritance-with-the-entity-framework-in-an-asp-net-mvc-application

  3. King, Gavin; Bauer, Christian; Andersen, Max Rydahl; Bernard, Emmanuel; Ebersole, Steve (September 15, 2010). "Chapter 9. Inheritance mapping". HIBERNATE - Relational Persistence for Idiomatic Java. Graphics design by James Cobb and Cheyenne Weaver (Version 3.5.6-Final ed.). Retrieved November 3, 2015. https://docs.jboss.org/hibernate/orm/3.5/reference/en/html/inheritance.html