我真的不知道如何命名我想要做的事情,所以我最好用具体案例来解释它。
我有树形表格:Product、ProductionReport和CommercialReference。
一个 CommercialReference 有一个 Product,而一个 Product 可以有多个 CommercialReference。此外,一个 ProductionReport 有一个 Product,并且一个 Product 可以存在于多个 ProductionReport 中。
我的问题是我想对我的产品进行一些版本控制。所以我们可以有“Gold Wheat v1、v2 等......”。我的 CommercialReference 应该 仅指出我的 Product 的“当前活动”版本(例如 ActiveVersion),但 ProductionReport 应该仅指出生产时的活动 Product .
如何在这些条件下建立ProductionReport和Product之间以及CommercialReference和Product之间的关系?
提前非常感谢您的回答。
注意:我的 Product 表有一个双主键(Id、Version),因此我与 ProductionReport 表建立关系没有问题,但是,当然,这不是我想要对我的 执行的操作商业参考表。 基本上,我想做的是:
您缺少一个实体。您需要诸如产品和产品版本之类的东西。这样您就有一个包含 ProductID 的 PK 的表用于 CommercialReference,而 ProductionReport 引用 ProductVersion。