the Main properties of inheritance
Association of inheritance, such Internal-InternalChild
called наследованием
class in the Association — предок
and the external потомок
.
Basic properties of inheritance
- When you inherit the attribute structure and composition of links is always increasing and can not be reduced (each inherited table stores
все
attributesвсех
ancestors). - The heir is available in the all attributes and associations of the ancestor. So, if we take an inner class
InternalChild
, its attributes will beAttr1
andAttr2
, mastersMaster1
,Master2
,Master3
, detailyDetail1, Detail2, Detail3, Detail4
. - Ancestor provides polymorphic access to all his heirs, which means that the instance of the inner class and its heirs (in this case
Internal and InternalChild
) can be set as an instance of the artisan class (in this caseMaster2
) and an instance of any heir of the master (in this caseMaster2Child
). The situation is similar with detaylari: instanceInternal
equally throughDetail2
operates with instances andDetail2 Detail2Child
, and similarly for attributes and methods of the class. In practice, this phenomenon can cause the problem to be solved with the help of a typeusage](fo_type-usage-problem.html) that in a particular way is displayed in the data structure. - If the heir has the attribute method (with the same composition parameters), the Association (with the same role name), it means that the heir
перегружает
this element ancestor. - Heir from the master can be detailon the same inner class (as in a situation
Internal-Master1-Detail4
), that’s fine.
Note: a Frequently asked question as to why the table of the heirs keep all attributes of all ancestors, not just their own. A: then when reading the object-the heir you need to collect all the attributes from the tables of their ancestors along the chain through
JOIN
which is very slow, especially when reading different types of objects in a single query. Therefore, application performance will decrease with increasing number of levels of inheritance, which is unacceptable.