1

I have a project where I have Products and SKU's. Each Product has one or many SKU's.

I also have Shops that can have many to many Products, So a Product can belong to multiple Shops and a Shop can have multiple Products.

To finish, each Shop can choose which SKU's they want for which Products. So I as a Shop can choose to sell the Tshirt White, which may have (XS,S,M,L) and I can choose (XS,S) as SKU's I want for my Shop.

Currently

As you can see A Shop is connected to the Products, and to the SKU's. But I have a feeling there's something wrong

My shop_skus and shop_products are not connected, So there can be a mismatch between the products a shop has, and the sku's..

How would I go about fixing that?

Thank you for your time!

enter image description here

MDCCL
  • 8,530
  • 3
  • 32
  • 63

1 Answers1

2

Edit: I didn't notice that this has been suggested already in comments by ypercube. So crediting him here.

Ultimately its up to you and your exact requirements. But here are following suggestions:

  1. SKUs does not exists if Products does not exist. In other words, you cannot make a SKU as a standalone entity. The basic entity therefore is Products. And as a Product can have multiple SKU, make this relationship many to many.
  2. So if you follow point 1, You can safely remove shop_skus relationship because now, a shop can select products via shop_products and as products are in many-many relationship with SKU you can enable shop to pick suitable SKU directly using suitable query.
Karan Desai
  • 173
  • 8