如果我有几个模型(命名你最喜欢的框架):
# pseudo-code
class Fruit
primary_key = CompositeKey(tenant_id, object_id)
weight = DecimalField()
class Restaurant
primary_key = CompositeKey(tenant_id, object_id)
haz_cheeseburger = BooleanField()
fruit_available = ForeignKey(Fruit) # <-- important part
是否有可能有一个数据库约束,这将使得无法插入主键指向的Resaturant
谁的一部分和谁的指向。基本上,保护我不会意外关联属于不同租户的对象。tenant_id
TenantA
fruit_available
tenant_id
TenantB