简体   繁体   English

多租户数据库中的查找

[英]Lookups in Multi-Tenant Database

I am developing a SaaS application and I am looking for the best way to design lookup tables, taking in consideration: 我正在开发一个SaaS应用程序,我正在寻找设计查找表的最佳方法,并考虑到:

  • The look-up tables will have predefined data shared among all the tenants 查找表将具有在所有租户之间共享的预定义数据
  • Each tenant must have the ability to extend the look-up table with his own data eg adding a car class not defined 每个租户必须能够使用自己的数据扩展查找表,例如添加未定义的汽车类

I am thinking about adding TenantID column to each lookup and add the predefined data with setting that column to some value which represents the "Super Tenant" that belongs to the system itself 我正在考虑将TenantID列添加到每个查找并添加预定义数据,并将该列设置为某个值,该值表示属于系统本身的“超级租户”

In a shared schema setup I would strongly recommend you identify the "owning" tenant of every table. 在共享架构设置中,我强烈建议您识别每个表的“拥有”租户。 Granted it's not always necessary, as child tables can be owned by parents which are owned by the tenant, but having the tenant on every table makes life much simpler and safer. 当然,并不总是必要的,因为子桌可以由租户拥有的父母拥有,但是每个桌子上都有租户,这使得生活变得更加简单和安全。 Having said that, I would use a special value for the tenant and either union or OR the select to get combined results. 话虽如此,我会为租户使用一个特殊值,或者使用union或OR来选择以获得组合结果。 You could use null, -1 or a well-known guid to represent the system. 您可以使用null,-1或一个众所周知的guid来表示系统。 My preference has been to use -1 recently. 我最近最喜欢使用-1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM