A
A
Alexander2017-10-03 16:28:07
Java
Alexander, 2017-10-03 16:28:07

How to make (bypass) foreign key on different tables?

So I have an OOP structure with an abstract object and its heirs. In another object there is a link to the parent class (where one of the heirs can be written), but when I tried to transfer this matter to the database, I went into a stupor, because FK roofing felts on one roofing felts on other table turns out. How is it solved?
Those. The question is about the structure of the database table.
PS I heard about polymorphic connections and that they are evil. But the problem is clearly not the first year there. How is it solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2017-10-04
@d-stream

You can remove the constraint, but this is fraught with a violation of consistency.
It is possible to conditionally make redundancy in the projections of objects (tables) in the form of several reference fields and a type field.
Naturally, neither is ideal. But one way or another, one has to find a compromise between multidimensionality (OOP) and its projections (relational databases). Hence the various options for non-relational databases

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question