In this article, we will see the product catalog database design and its associations. The below diagram explains the entities involved and their associations.
Let me justify the above entities associations, as MongoDB has an embedded document approach and refer one document to another document.
Product to Category association chosen as a reference-based approach. Because the product can be associated with 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 a 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 the reference-based approach will enable us to detach the in-house management of the review system and choose above said 3rd party solutions.
Product to Inventory association, here again, I have chosen a reference-based approach. Because, the inventory is referenced by multiple systems like a customer service center, point of sales(POS) and online system, etc. Some times inventory may not be part of an e-commerce system rather it is maintained by ERP systems. In that case following the reference-based approach enable us to remove managing of inventory in the 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 anyone wants to provide inputs or want to debate on the above product catalog design, it is very much appreciated.