J
J
Jake Taylor2021-07-08 10:59:00
Database design
Jake Taylor, 2021-07-08 10:59:00

How to correctly create a table of two types of users in the database?

The database is being designed. The site should have account types with columns listed in brackets:
- Individual (last name, first name, email, password);
- Legal entity (last name, first name, email, password + company name, company's UNP).

There are common data: last name, first name, email, password , which can be placed in a separate table, let's call it accounts . Right? What should be the tables then in the database? The accounts table, the individuals table and the company table like this:
60e6affbe2923344462976.jpeg

either create only one accounts table and where the user will have the role = "Individual", null fields will be filled in, which must be filled in the company, and these are the fieldscompany name, UNP company ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2021-07-08
@n199a

Because of the 3 fields, there is absolutely no point in creating separate tables. You will lose more in performance by constantly using JOIN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question