[英]Creating table relationships correctly
I have a form for an invoice creation and my task is that I want a user to be able to limit a customer's selection of data from a database based on selections the user has previously made. 我有一个用于创建发票的表格,我的任务是希望用户能够基于用户先前所做的选择来限制客户从数据库中选择数据。
My constraints are that each company has access to all products but the price for the same product will be different for different companies. 我的约束是,每个公司都可以使用所有产品,但是同一产品的价格对于不同的公司将有所不同。 Also each product may come in different sizes, which will have different prices.
每个产品的尺寸也可能不同,价格也不同。
Need help understanding the logic behind creating the connections between these classes. 需要帮助来了解在这些类之间创建连接的逻辑。
For instance my entities: 例如我的实体:
Company (attributes: CustID, Name, ShipTo, SoldTo, City, State, ZipCode)
Product (attributes: UN, Name, Hazard, Packing Class, Grade, Weight, Unit Type)
Now each product can come in many sizes, and each size has many products associated with it. 现在,每种产品可以有多种尺寸,每种尺寸都有许多与之关联的产品。 So I created a junction table titled
Type
with attributes Size
and UN
and linked in the Product and Type table together. 因此,我创建了一个名为
Type
的联接表,该联接表具有Size
和UN
属性,并在Product和Type表中链接在一起。
Then I created another junction because each company could have the same product and each product could be sold to many companies, and titled it CustProduct
with attributes CustID
and UN
and linked it to Product table and Company Table. 然后,我创建了另一个联结,因为每个公司可以拥有相同的产品,并且每个产品都可以出售给许多公司,并使用属性
CustID
和UN
将其命名为CustProduct
并将其链接到Product表和Company Table。
Now I'm getting confused, how and where do I create a relationship that will allow link a unique price to product
with a determinable size
sold to a specific Company
? 现在我越来越糊涂,怎么和我在哪里创建关系,将允许链接一个独特的价格
product
具有确定的size
出售给特定的Company
? Banging my head on this. 敲我的头。
From what you're saying, here is what I think: 根据您的意思,这是我的想法:
This means that each company can specify the price for each size of each product. 这意味着每个公司都可以为每种产品的每种尺寸指定价格。
I hope that helps. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.