Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I split the data between multiple databases or keep them in a single one?

I'm creating a multi-user/company web application in PHP & MySQL. I'm interested to know what the best practice is with regards to structuring my database(s).

There will be hundreds of companies and thousands of users of this web app so this needs to be robust. Each company won't be able to see other companies data, just their own. We will be storing mainly text data and will probably only be a few MB per company.

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

Is it better to put the data for all companies and their users in a single database and create a unique companyID for each one?

or:

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

What are the pluses and minuses to each approach?

Thanks,

Stephen

like image 231
salonMonsters Avatar asked Dec 15 '09 23:12

salonMonsters


People also ask

When should you split a database?

Consider splitting any database that several people share over a network. Splitting a shared database can help improve its performance and reduce the chance of database file corruption. After you split database, you may decide to move the back-end database, or to use a different back-end database.

Is it okay to use multiple databases?

Try to avoid multiple databases or tables with the same design or purpose. Multiple database apps are usually apps which have their own data requirements but also have to integrate with another existing app or service's database.

How can we use two databases to a single application?

so, based on user login, the application should connect different database server. For Ex: if user "xxx" login with credential and belogs to "ABC" company and the database is "ABC", then ABC data need to display on the web page.

Can ETL combine data from multiple databases?

In the Etlworks Integrator, it is possible to read data from one dataset and load it into multiple database tables.


1 Answers

If a single web app is being used by all the different companies, unless you have a very specific need or reason to use separate databases (it doesn't sound like you do), then you should definitely use a single database.

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

like image 134
philfreo Avatar answered Nov 05 '22 04:11

philfreo