Let us say I need to design a database which will host data for multiple companies. Now for security and admin purposes I need to make sure that the data for different companies is properly isolated but I also do not want to start 10 mysql processes for hosting the data for 10 companies on 10 different servers. What are the best ways to do this with the mysql database.
There are three approaches on how to build a multi-tenant application: Database per tenant — each tenant has its database. Shared database, separate schema — all tenants are using the same database, but each tenant has his schema. Shared database, shared schema — all tenants are using the same schema.
Multi-tenancy is an architecture in which a single instance of a software application serves multiple customers. Each customer is called a tenant.
A multi-tenant OpenEdge database is a shared database with a shared schema and logically and physically isolated data storage on a per tenant or group basis. Each object (table, index, LOB) is stored in a partition. Partitions keep data physically separate for each tenant.
You can have as many schemas as you like, e.g., as has been suggested, a development schema and a prodcution schema. They can both be stored in the same database server and can contain exactly the same content.
There are several approaches to multi-tenant databases. For discussion, they're usually broken into three categories.
MSDN has a good article on the pros and cons of each design, and examples of implementations.
For reference, this is the original link for the second article
In MySQL I prefer to use a single database for all tenants. I restrict access to the data by using a separate database user for each tenant that only has access to views that only show rows that belong to that tenant.
This can be done by:
I've fully documented this in a blog post: https://opensource.io/it/mysql-multi-tenant/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With