如何设计一个多租户的mysql数据库
假设我需要设计一个数据库,该数据库将托管多个公司的数据.现在出于安全和管理目的,我需要确保不同公司的数据被正确隔离,但我也不想启动 10 个 mysql 进程来在 10 台不同的服务器上托管 10 家公司的数据.使用 mysql 数据库执行此操作的最佳方法是什么.
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 several approaches to multi-tenant databases. For discussion, they're usually broken into three categories.
- 每个租户一个数据库.
- 共享数据库,每个架构一个租户.
- 共享数据库,共享架构.租户标识符(租户键)将每一行与正确的租户相关联.
MSDN 有一篇关于 每种设计的优缺点,以及实现示例.
MSDN has a good article on the pros and cons of each design, and examples of implementations.
<小时>微软显然已经删除了我提到的页面,但它们在 archive.org 上.链接已更改为指向那里.
Microsoft has apparently taken down the pages I referred to, but they are on on archive.org. Links have been changed to point there.
作为参考,这是第二篇文章的原始链接一个>
相关文章