A
A
Arturbalagur2022-04-11 10:46:46
Database design
Arturbalagur, 2022-04-11 10:46:46

How to correctly build a database for applications?

Many companies can register on the site. They can create applications.
Of course, I implemented it, but VERY poorly (as it seems to me).
1) Applications are attached to the company by id.
2) Only one table has been created for all applications.

-- Table "companies" --
6253da6b6b737807453151.png

-- Table "requests" --
6253daaec4f9c696830857.png

They are actually related.
It seems to me that you need to make separate tables for each company. How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2022-04-11
@Arturbalagur

1) Applications are attached to the company by id.

What's the problem? If the tables are connected via FK at the base level, then everything is ok. Relational databases are just for this and did.
2) Only one table has been created for all applications.
It seems to me that you need to make separate tables for each company. How to do it right?

Why such perversion? What problem do you want to solve by adding a new table for each company?
If there is no specific reason (moreover, a very weighty one) for which you need to implement something like this, use the current solution, because at least the question arises: how will you cut requests? Prepeared statments/pdo does not allow table names to be substituted. Without them, there will be a security problem. To solve it, you will need to fence extra code, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question