[odb-users] Polymorphic inheritance

Boris Kolpackov boris at codesynthesis.com
Wed Feb 29 12:52:39 EST 2012


Hi Wesley,

Wesley Harris <wesmharris at gmail.com> writes:

> I noticed that the docs say that polymorphic inheritance is not yet
> supported. Is there any time frame on when it will be implemented?

We are actually planning to add this support for the next release and
I hope to have something ready to try in a few weeks, if you are
interested.

Also, there are generally three different approaches to modeling
polymorphic inheritance in the database:

1. Table per hierarchy, where all derived objects belonging to a 
   hierarchy are stored in a single table.

2. Table per difference, where additional columns corresponding to
   the derived classes are stored in additional tables.

3. Table per class, where each class in a hierarchy gets its own
   independent table that contains all its members.

The first approach is the most inflexible: you have to provide the so-
called discriminator (basically a value that distinguishes different
classes) and the whole hierarchy must be known at compile-time (e.g.,
reside in a single header or similar). But it is also the most
efficient in terms of the database statements that need to be 
executed.

The second and third approaches are more flexible but are generally
not as efficient as the first one.

Do you have any preference as to which approach would work best in
your case?

Boris



More information about the odb-users mailing list