[odb-users] Inheritance

Kuentzer, Jan jan.kuentzer at roche.com
Fri Jul 8 08:20:49 EDT 2011


Hi Boris,

Thanks for the fast reply !

> Yes, this is an example of polymorphic inheritance which is still on the TODO list. 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 reside in a single header. But it is also the fastest.
>
> 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?

I would think the third (or second) should work fine, since this would result in no change of the kernel classes. However, I cannot image how the performance difference would be? Should be still okay for us I guess. The question is after a query do you get the example objects as instance of permanent_employee or only employee? We would need to know the type of the class.

>
> There is also a way to emulate polymorphic inheritance for the time being that will work well with load() and object relationships but won't handle queries. Let me know if you would be interested in this and I will elaborate.

If there is a emulation I would be interested since I like your project and it would save me a lot of time and effort. But I rely on the predefined data model based on the polymorphic inheritance. For the time being the load() would be okay and I could add queries as soon as ODB supports polymorphic inheritance.
Thanks for the help and this really nice project!


Best

            Jan




More information about the odb-users mailing list