Should I split the data between multiple databases or store them in one?

I am creating a multi-user / corporate web application in PHP and MySQL. I am interested to know what is best for structuring my database.

There will be hundreds of companies and thousands of users in this web application, so this should be reliable. Each company will not be able to see the data of other companies, only their own. We will mainly store text data and probably only have a few MB for each company.

Currently, the database contains 14 tables (for one typical company).

Is it better to place data for all companies and their users in one database and create a unique company identifier for each of them?

or

Is it better to put the data of each company in its own database and create a new database and table for each new company that I add?

What are the pros and cons for each approach?

Thanks,

Stephen

+3
source share
4 answers

If one web application is used by all different companies, if you have no special needs or reasons to use separate databases (this does not look like what you are doing), then you definitely need to use one database.

Your application will only be responsible for displaying the correct information to authenticated users.

+7
source

. . , 14 +.

, -, , Access - .

+3

. , . , , .

+2

Multi-

  • : .
  • , .
  • : .
  • , .

  • , . . .
  • , .

  • , . .
  • , ( A B). , , .
  • SQL,

  • , . , , .
  • Including data from multiple databases in a single query is usually complex and often requires trained operators.
  • The development is complicated, because you need to make the same changes to several schemes.
  • The same database object may appear in many databases with different identification keys, which leads to confusion.
  • Converting a single-tenant to a multi-tenant setup is very difficult if you need to change your design.
+1
source

Source: https://habr.com/ru/post/1725783/


All Articles