<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Single_Table_Inheritance</id>
	<title>Single Table Inheritance - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Single_Table_Inheritance"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Single_Table_Inheritance&amp;action=history"/>
	<updated>2026-10-25T21:05:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Single_Table_Inheritance&amp;diff=6322035&amp;oldid=prev</id>
		<title>imported&gt;Frap: /* Example */</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Single_Table_Inheritance&amp;diff=6322035&amp;oldid=prev"/>
		<updated>2024-02-12T09:56:57Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Example&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Single table inheritance&amp;#039;&amp;#039;&amp;#039; is a way to emulate [[object-oriented]] [[inheritance (object-oriented programming)|inheritance]] in a [[relational database]].  When [[Map (mathematics)|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.&amp;lt;ref&amp;gt;{{cite book |last=Fowler |first=Martin |authorlink=Martin Fowler (software engineer) |others=Contributions by Dave Rice, Matthew Foemmel, Edward Hieatt, Robert Mee, and Randy Stafford |date=2003 |title=Patterns of Enterprise Application Architecture |series=The Addison-Wesley Signature Series |publisher=Addison-Wesley |isbn=0-321-12742-0 |page=278}}&amp;lt;/ref&amp;gt; All fields of all the classes are stored in the same table, hence the name &amp;quot;Single Table Inheritance&amp;quot;.   In [[Ruby on Rails]] the field in the table called &amp;#039;type&amp;#039; identifies the name of the [[class (computer science)|class]].  In [[Hibernate (Java)]] and [[Entity Framework]] this pattern is called  Table-Per-Class-Hierarchy and Table-Per-Hierarchy (TPH) respectively.,&amp;lt;ref&amp;gt;{{cite web |date=January 21, 2019 |title=Tutorial: Implement Inheritance with EF in an ASP.NET MVC 5 app |url=http://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 |accessdate=November 3, 2015}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |last1=King |first1=Gavin |last2=Bauer |first2=Christian |last3=Andersen |first3=Max Rydahl |last4=Bernard |first4=Emmanuel |last5=Ebersole |first5=Steve |others=Graphics design by James Cobb and Cheyenne Weaver |date=September 15, 2010 |title=Chapter 9. Inheritance mapping |edition=Version 3.5.6-Final |work=HIBERNATE - Relational Persistence for Idiomatic Java |url=https://docs.jboss.org/hibernate/orm/3.5/reference/en/html/inheritance.html |accessdate=November 3, 2015}}&amp;lt;/ref&amp;gt; and the column containing the class name is called the Discriminator column.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Blogs&lt;br /&gt;
|-&lt;br /&gt;
! BlogId !! Discriminator !! Url !! RssUrl&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Blog || &amp;lt;nowiki&amp;gt;https://blogs.example.com/pets&amp;lt;/nowiki&amp;gt; || {{Null result}}&lt;br /&gt;
|-&lt;br /&gt;
| 2 || RssBlog || &amp;lt;nowiki&amp;gt;https://blogs.example.com/cars&amp;lt;/nowiki&amp;gt; || &amp;lt;nowiki&amp;gt;https://blogs.example.com/cars.rss&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The table have the &amp;lt;code&amp;gt;Url&amp;lt;/code&amp;gt; which is used by all blogs but only blogs of type RssBlog have a value assigned in the &amp;lt;code&amp;gt;RssUrl&amp;lt;/code&amp;gt; column, other rows have &amp;lt;code&amp;gt;NULL&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Object–relational mapping]]&lt;br /&gt;
* [[ActiveRecord (Rails)]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{Reflist}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* [http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html Single Table Inheritance]&lt;br /&gt;
* [http://www.yiiframework.com/wiki/198/single-table-inheritance/ Single Table Inheritance in Yii]&lt;br /&gt;
* [https://github.com/craigds/django-typed-models Single Table Inheritance in Django]&lt;br /&gt;
&lt;br /&gt;
[[Category:Database theory]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{software-eng-stub}}&lt;/div&gt;</summary>
		<author><name>imported&gt;Frap</name></author>
	</entry>
</feed>