我有一个 SellerProduct 表。表格中的每一行代表卖家提供的产品信息。SellerProduct 表具有以下列:
id (serial, pk)
productName (nvarchar(50))
productDescription (ntext)
productPrice (decimal(10,2))
sellerId (int, fk to Seller table)
一个产品在卖家之间可能是相同的,但 productName、productDescription 和 productPrice 可能因卖家而异。
例如,考虑产品 TI-89。卖家 A 可能拥有该产品的以下信息:
productName = TI-89 Graphing Calc
productDescription = A graphing calculator that...
productPrice 65.12
卖家 B 可能拥有该产品的以下信息:
productName = Texas Instrument's 89 Calculator
productDescription = Feature graphing capabilities...
productPrice 66.50
管理员用户将需要识别不同卖家的产品是否相同。
我需要一种方法来捕获这些信息(即产品在卖家之间是相同的)。我可以创建另一个名为 SellerProductMapper 的表,如下所示:
sellerProductId1 (int, pk, fk to SellerProdcut table)
sellerProductId2 (int, pk, fk to SellerProdcut table)
这种方法的问题在于它允许sellerProductId1 和sellerProductId2 来自给定行的同一个卖家。那不应该被允许。
如何在强制执行此约束时捕获这种多对多关系?