0

I have question regarding joining tables using composite keys.

If I have two tables: "Sales" and "Items" with a M:M relationship between them and my data schema included a joining table called "SalesItems" with two composite keys only (saleID, ItemID).

What would the relationship be between "Sales and "SalesItems" be?, and what would it be between "Items" and "SalesItems" (i.e. 1:M)?

1

Based on every sales business process I've come across;

Sales : SalesItems = 1:M

  • Every sales item header has one or many sales items
  • Each Salesitem has only one header

Items:SalesItems = M:1

  • A given item can appear in zero, one, or many SalesItems records
  • Every SalesItems record has only one item

If this is a academic question then that will suffice. If this is a real world question, you need to understand your business process:

  • Is it possible to raise a sale with no items?
  • Do you have SalesItems that don't describe items (i.e. tax and services?)
  • Thanks for your reply. So to clarify, Sales (1:M) salesItems (M:1) Items – Jared Jun 16 '17 at 5:35
  • Yep thats correct – Nick.McDermaid Jun 16 '17 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.