In this article, we will look at a product catalog database design and its associations. The diagram below explains the entities involved and their associations.
Let me justify the above entities associations, as MongoDB has an embedded document approach and refers one document to another document.
Product to Category association is 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 belonging to that category.
Product to Reviews association is chosen as a reference-based approach because the reviews are user-generated content and will grow over time. If I choose reviews as embedded documents, then whenever the review is given by the shoppers, the product should undergo for update and MongoDB has a limit on the single document size of 16 megabytes. The other reason is that sometimes we don’t want to manage reviews in our e-commerce system, but rather we will go with 3rd party integrations like Bazzarvoice or Yotpo. Going with a rreference-based approach will enable us to detach the in-house management of the review system and choose the above mentioned 3rd party solutions.
Product to Inventory association — here again, I have chosen a reference-based approach because the inventory is referred by multiple systems like customer service center, point of sales(POS), and online system etc... Sometimes inventory may not be part of an e-commerce system, but rather it is maintained by ERP systems. In that case, following a reference-based approach enables us to remove managing of inventory in the e-commerce system and use a 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 input or debate about the above product catalog design, it is very much appreciated.