Answer the question
In order to leave comments, you need to log in
How to create a database schema that has an entity with various additional properties?
There is a user user, which can be either natural (natural) or legal (legal) person. How correct is it to create a scheme of the following type:
requests will be with join and both types of persons at once, and separately
user
----
id int
person string (legal|natural)
person_legal
----
id int
user_id int
prop_1
...
person_natural
----
id int
user_id int
prop_2
...
user
----
id int
person string (legal|natural)
user_props
-------
id int
user_id
prop
value
Answer the question
In order to leave comments, you need to log in
Of the options, the first one was chosen, although there was a desire to use json as the field value. But the first case is notable because postgresql has inheritance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question