Mapping of inherited object structures
Being object inheritance one of the most used features in object oriented design, it has come out to fit difficulty in relational structures. With a wide range of mapping possibilities depending on database design and legacy systems, you can reach the best performance.
See our demo implementing all 3 types of inheritance mappin
Following inheritance mappings are currently supported in DADO Database MapperŪ:
In this scenario we map the properties of the base class in a table and the properties of the inherited objects in separate tables. This optimizes database but makes the queries more time consuming, requiring a join operation.
In this scenario we map all the properties of an object (and its base objects) on the same table. Every inherited object has its own table. While optimizing database space and query performance (usually no join required) this makes impossible to search on base types (in this case the type "Animal")
In this scenario we map two different object types on the same table. This can be on different columns or even on shared columns with different meaning depending of the object type (for example the column "Owner" may mean "DogOwner" in case of a dog or "Parent" in case of a man).
While this is the fastest solution during queries on base types, it increases database complexity and of course required space.
As seen above the ways to map inheritance are different, and any one brings advantages and disadvantages. If not working with a legacy database schema (where there is no choice), the best choice depends of the requirements.