Comparison
Object-relational impedance mismatchvsSingle table inheritance
Object-relational impedance mismatch
inheritance, collections and object identity all had to become foreign keys, and none of the three translations were free.
The structural gap between an object model — identity, references, inheritance, encapsulation — and a relational one — keys, joins, tables, no behaviour. It is why mapping inheritance requires a choice of three imperfect strategies, why a collection becomes a join table, and why object identity and primary keys are not the same thing. Naming it is what stops a team believing there is a mapping tool somewhere that does not have these problems.
Full entry →Single table inheritance
one table holds three kinds of thing, a type column says which, and most columns are null for most rows.
Mapping a whole inheritance hierarchy to one table with a discriminator column and the union of all subclass fields. It is the simplest of the three inheritance mapping strategies and the fastest to query, at the cost of nullable columns that the database cannot constrain. The alternatives — a table per class, or a table per concrete class — move the cost to joins or to duplicated columns instead; none of the three is free, which is the impedance mismatch in miniature.
Full entry →