2 ms·
I find inheritance vs. composition to be much less an issue in RDBMSes vs. OOP languages. The problem with inheritance in OOP is that you inherit the code, but
by colanderman 8y ago
I find inheritance vs. composition to be much less an issue in RDBMSes vs. OOP languages. The problem with inheritance in OOP is that you inherit the code, but not the data (at least, it is supposed to be hidden). This results in overly tight coupling between your class and the other class that you just need a piece of and (I find) is almost never what you want (rather preferring composition and interfaces).
Whereas in an RDBMS, there is no "code" attached to a relation; and the data is explicitly exposed. Inheritance starts to look more like the typical pattern of structure with common fields at the top level, and disjoint fields inside a discriminated union. You can mirror this with RDBMS composition (foreign keys), but you lose the ability to enforce even basic structural constraints (tricks like mutually-referential foreign keys notwithstanding).