简体   繁体   中英

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:

  • 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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