Mapping rules for inheritance relationships¶
One table per class hierarchy¶
- The SQL table must have a field for each property declared by the inheritance tree’s persistent classes.
- The SQL table must have an extra field for the discriminator.
- The fields of the SQL table cannot have the Not Null constraint.
One table per child class¶
- Child class tables have a primary key associated with the parent class’ table (the relational model is a one-to-one association).
The SQL Designer module supports a variant of this strategy (one table per child class using a discriminator), which leads to the following constraints:
- The Discriminator Column, Discriminator Column Type and Discriminator Value properties must be defined at parent class level.
- The SQL table corresponding to the parent persistent class must have a column for the discriminator.
One table per concrete class¶
- Each SQL table defines columns for all the properties of the class, including inherited properties.
- The name of the column corresponding to Property must be the same for all the child classes.
One table per concrete class using implicit polymorphism¶
- Each SQL table defines columns for all the properties of the class, including inherited properties.
- The name of the column corresponding to Property must be the same for all the child classes.