A
A
Alexey Nevzorov2019-03-15 15:55:38
Database design
Alexey Nevzorov, 2019-03-15 15:55:38

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
...

or:
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

1 answer(s)
A
Alexey Nevzorov, 2019-03-15
@proghermit

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 question

Ask a Question

731 491 924 answers to any question