Reputation: 45
I am building a database which consists of a
table of category, customer table
, and table of product which fetches information from categories.
Now I need a new table for sale which consists of customerID, date, productID
. My problem is
the customer may buy many products. how can I make the relation between them in SQL Server 2008?
Upvotes: 3
Views: 461
Reputation: 20320
Your drawing commented on in @orn's answer only makes sense if each sale can only involve one product.
Mr Fliim put you on the right track to deal with multiple products in one sale.
Upvotes: 1
Reputation: 2189
Customer {id, name, ...}
Product {id, name, ...}
Sale {product_id, customer_id, order_id, qty, ...}
Order {id, date, ...}
Upvotes: 4
Reputation: 3485
Just add a order table, the order table will keep reference to the products in the order.
Upvotes: 1