A
A
abberdeen2020-08-10 09:05:04
MySQL
abberdeen, 2020-08-10 09:05:04

Polymorphism in a database, how to organize tables?

Good afternoon,

I have a question about designing table relationships. There is an entity "Seller", the seller can be either "Organization" or "Person", the question is, how to establish links between these entities?
It is necessary that there are real relationships between entity tables, with keys, without type fields, etc. etc.

You cannot:
- For the entities "Organization" and "Person", you cannot put the field "Seller ID", because they may not be sellers,
- For the entity "Seller", you cannot simply put the fields "Organization ID" and / or "Human ID", so wrong.

I imagine it like this:

5f30e29986614378592087.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2020-08-10
@abberdeen

Well, you can focus on the contragent_type - which will determine at least 3 entities: an organization (legal entity), a person (individual) and an individual entrepreneur (an individual with elements of an organization), plus, more recently, a subtitle of an individual entrepreneur - self-employed. In this vein - the seller is always the contragent, but depending on the contragent_type - within the framework of the counterparty - there are already several intersecting entities. Moreover, the organization will include at least a handful of people (director, accountant, contact persons, responsible, signatories, etc.). Moreover, due to the existing realities of the plurality of companies, the same person can appear both as a fl and as a contact person in several companies and as an accountant director in several more ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question