Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In single-table inheritance, a single table can be used for more than one entity. The most sure way to do this is to use a column, or a set of columns, that have ordinal values.

An example would be:<table border="1">
<caption>Table: Sellables</caption>
<tr><th>pk</th><th>name</th><th>cost</th><th>objType</th></tr>
<tr><td align="right">1</td><td align="right">Corvette</td><td align="right">50000</td><td align="right">1</td></tr>
<tr><td align="right">2</td><td align="right">Volkswagen</td><td align="right">10000</td><td align="right">1</td></tr>
<tr><td align="right">3</td><td align="right">Piper Cub</td><td align="right">50000</td><td align="right">2</td></tr>
<tr><td align="right">4</td><td align="right">Lear Jet</td><td align="right">100000</td><td align="right">2</td></tr>
</table>

Table: Sellables

Section
borderfalse

pk

name

cost

objType

1

Corvette

50000

1

2

Volkswagen

10000

1

3

Piper Cub

50000

2

4

Lear Jet

100000

2

One can create two entities. In one entity, called "Cars", the external name would be "Sellables" and there would be a restricting qualifier saying that "objType = 1". For another entity, called "Planes", the external name would also be "Sellables" and there would be a restricting qualifier saying that "objType = 2".

...