In this article we will see the product catalog database design and its associations. The below diagram explains the entities involved and its associations.
Let me justify the above entities associations, as MongoDB has embedded document approach and refer one document to other document approach.
Product to Category association chosen as reference based approach. Because, the product can be associated to multiple categories and categories can be modified by business users. So when the category goes with modification, I don’t want to update the products belongs to that category.
Product to Reviews association chosen as reference based approach. Because, the reviews are user generated content and it will grow over the period. If I choose reviews as embedded documents, then whenever the review is given by the shoppers, then the product should undergo for update and MongoDB has a limit on the single document size as 16 megabytes. The other reason is, some times we don’t want to manage reviews in our e-commerce system rather we will go with 3rd party integrations like Bazzarvoice or Yotpo kind of solutions. Going with reference based approach will enable us to detach the in-house management of review system and choose above said 3rd party solutions.
Product to Inventory association, here again I have chosen reference based approach. Because, the inventory is refered by multiple systems like customer service center, point of sales(POS) and online system ect… Some times inventory may not be part of e-commerce system rather it is mantained by ERP systems. In that case following reference based approach enable us to remove managing of inventory in e-commerce system and use 3rd party inventory system.
The detailed field list of each entities document is given below.
Catalog Document Structure:
Category Document Structure:
Product Document Structure:
Inventory Document Structure:
Reviews Document Structure:
If any one want to provide inputs or want to debate on the above product catalog design, it is very much appreciated.