Reputation: 1023
I am having a massive confusion as Im trying to develop an ERD Diagram and am confused by this statement. I am trying to relate two entities. they are "order" and "products". So im confused about the cardinality of these two. will it be 1 order will have many products or will it be 1 product can be ordered many times. BTW my entities for my ERD are. Customers, Products, Sales, Orders, Staff. Thank you very much.
Upvotes: -2
Views: 488
Reputation: 1
I think that the cardinality relies on what you mean exactly by the word product. If the product represents a category under which all the instances of the product fall (the product type has a unique ID), then the relationship between order and product would be many-to-many, as the product type could be purchased multiple times and the order could include multiple product types. If the product represents an instance of the product (each product instance has a unique ID), then the relationship would be each order could have many products but the product can only be involved in one order.
Upvotes: 0
Reputation: 26
I would suggest go for many to many. You'll need another auxiliary entity (data from whose table should not be exposed to the user) such as OrderProductMap.
It will let you maintain orders, and a list of products. In case of one to many from Order to Product, each order will have to create a separate product instance, which is not a natural thing to do. The opposite is not sound either. An order should NOT be limited to a single product.
Upvotes: 1
Reputation: 2826
Not a lot of detail to work with here, but I would say almost certainly that it's "1 order will have many products."
Upvotes: 0