我有几个表:company、customer、company_has_customer和transaction。
company_has_customer是一个多对多联结表,使用company和customer作为其 PK。
在整个数据库的几乎所有情况下,company和customer都用于标识一条记录(例如在transaction表中)。
我的问题是我是否应该在transaction表中创建外键以分别指向company_has_customer或指向两个表(company, customer)?
我认为,最好将这些 FK 发送到参照完整性,company_has_customer以确保transaction仅在公司与客户之间存在关系时才插入记录。是否有任何标准或约定来支持我的预感?