Mysql – Need Help maintaining multiple databases for a multi-tenant application

database-designdatabase-tuningmulti-tenantMySQL

i need some information about multiple databases for a multi-tenant application ?

I am working on a project in which we are maintaining separate database for every company?

The Companies Database contain customer Data.

There is a common Database to store common information across these databases. Example Customer ID,Customer Contact Number and Customer Email etc.

A New Database is created for every new company.

If one customer belongs to company1 and same customer is added in company 2
then we need to give same customer id from company 1 to that customer across all companies.

There are many such scenarios similar to the above example.

Can any one tell me how to manage multiple databases(companies) and same customers across all companies.

Best Answer

You should store all information that is common for all companies in one database and copy the data that are needed to the database that needs the information. Adding a new customer would be done in the common db. After that the information will be copied to company1. If it's needed in company2, then the data will be copied to company2. Make sure you also add an update process to keep the copied information in sync. Alternatively, you could keep the customer information in the main db and link to it. However, this would only be recommended if all db's are on the same SQL Server instance.