Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

MongoDB — Design of Product Catalog Documents Structure

DZone's Guide to

MongoDB — Design of Product Catalog Documents Structure

In this article, we will analyze a product catalog database design and its associations. Read on for more info.

Free Resource

Read why times series is the fastest growing database category.

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.

Mongodb product catalog document structure and 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:

mongodb product catalog document structure and associations






Category Document Structure:

mongodb product catalog document structure and associations









Product Document Structure:

mongodb product catalog document structure and associations

Inventory Document Structure:

mongodb product catalog document structure and associations








Reviews Document Structure:

mongodb product catalog document structure and associations








If anyone wants to provide input or debate about the above product catalog design, it is very much appreciated.

Learn how to get 20x more performance than Elastic by moving to a Time Series database.

Topics:
product catalog ,mongodb ,nosql

Published at DZone with permission of Siva Prasad Rao Janapati, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}