Consider this highly simplified sample of relational data (each table may be involved in one-to-many and many-to-many relationships not shown here):
people +-------+------+--------+ | name | born | gender | +-------+------+--------+ | Alice | 1980 | F | | Bob | 1975 | M | | Carl | 1994 | M | | Dot | 1942 | F | +-------+------+--------+ workers students +-------+---------+-------+ +-------+-------------+-------+ | name | company | since | | name | institution | since | +-------+---------+-------+ +-------+-------------+-------+ | Alice | Soylent | 2003 | | Alice | Western | 2001 | | Bob | HAL | 1999 | | Carl | Eastern | 2012 | +-------+---------+-------+ +-------+-------------+-------+ Some people are workers (Bob), some are students (Carl), some are neither (Dot).
Some are both (Alice).
Mapping to OOP, it would be straightforward to have three classes, like:
class Worker extends Person class Student extends Person But that's ok as long as the specialization is disjoint: object alice can't be instance of Worker and Student at the same time. If you get a list of Person objects, you cannot cast the same element to both subclasses.
First of all, is there any specific name for this (likely common) impedance mismatch case?
Next, suppose you can't remodel the schema. I may have my own way to workaround with OOP, but I'm mainly interested in yours. Is there some sort of best-practice guideline?
This example has only two ISA relations, but my impression is, the more non-disjoint sub-entities, the more OOP gets uncomfortable.