每次我看到大约多租户数据库模型的教程告诉你把TenantID在每一个表:Multitenant DB:为什么要在每个表中放置一个TenantID列?
zoos
-------
id
zoo_name
tenant_id
animals
-------
id
zoo_id
animal_name
tenant_id
然而,这似乎是多余的给我。为什么不将tenant_id
列添加到zoos
表中并利用zoos
和animals
之间的外键关系?
你是否为每个表添加tenant_id
以防止连接过度疯狂?它是防范错误的保护措施吗?性能考虑?
设计多租户数据库时有一些注意事项,请阅读MSDN文章:[多租户数据架构](http://msdn.microsoft.com/en-us/library/aa479086.aspx)总之,有几个方法,它是选择和后果的连续体。根据需求做出明智的决定。 – 2012-01-11 09:47:32