[英]Multi tenancy design - sharing data between schemas
Let's consider such case:让我们考虑这样的情况:
Now given the circumnstaces above, I want to implement a system in which each company (tenant) has a separate schema for its tasks, but the problem is that for each task I also need a user data from the main schema.现在考虑到上述情况,我想实现一个系统,其中每个公司(租户)都有一个单独的任务模式,但问题是对于每个任务,我还需要来自主模式的用户数据。
The question is how to approach this problem问题是如何解决这个问题
The possible solutions I have thought of (but none is really convincing me):我想到的可能的解决方案(但没有一个真正让我信服):
I hope there is a better solution I haven't thought of.我希望有一个我没有想到的更好的解决方案。 Please note that this is a simplified case, just to describe the problem.
请注意,这是一个简化的案例,只是为了描述问题。
It sounds like you want a handful of tables, like users
, companies
, tasks
, and related tables.听起来您想要一些表,例如
users
、 companies
、 tasks
和相关表。
In general, you do not want to split entities across multiple tables.通常,您不希望跨多个表拆分实体。 Here are some reasons.
以下是一些原因。
There are some rare circumstances where it makes sense to separate data.在一些罕见的情况下,分离数据是有意义的。 For instance, if the application is going to be on-premise at each company, then you have no choice.
例如,如果应用程序将在每个公司内部部署,那么您别无选择。 Similarly, you might have legal requirements for keeping data physically separate.
同样,您可能有将数据物理隔离的法律要求。 But from a strict database-design perspective, you want one table per entity.
但是从严格的数据库设计角度来看,您需要每个实体一个表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.