开发者

Lookups in Multi-Tenant Database

开发者 https://www.devze.com 2023-01-12 10:57 出处:网络
I am developing a SaaS application and I am looking for the best way to des开发者_开发百科ign lookup tables, taking in consideration:

I am developing a SaaS application and I am looking for the best way to des开发者_开发百科ign lookup tables, taking in consideration:

  • 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 e.g 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


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. You could use null, -1 or a well-known guid to represent the system. My preference has been to use -1 recently.

0

精彩评论

暂无评论...
验证码 换一张
取 消