MongoDB – Design of Product Catalog Documents Structure

Ecommerce with Node.js, MongoDB, Elasticsearch

                           In this article we will see the product catalog database design and its associations. The below diagram explains the entities involved and its associations.

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

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 any one want to provide inputs or want to debate on the above product catalog design, it is very much appreciated.

Advertisements

I am Siva Prasad Rao Janapati. Working as a software developer. Has hands on experience on ATG Commerce(DAS/DPS/DCS), Mozu commerce, Broadleaf Commerce, Java, JEE, Spring, Play, JPA, Hibernate, Velocity, JMS, Jboss, Weblogic,Tomcat, Jetty, Apache, Apache Solr, Spring Batch, JQuery, NodeJS, SOAP, REST, MySQL, Oracle, Mongo DB, Memcached, HazelCast, Git, SVN, CVS, Ant, Maven, Gradle, Amazon Web services, Rackspace, Quartz, JMeter, Junit, Open NLP, Facebook Graph,Twitter4J, YouTube Gdata, Bazzarvoice,Yotpo, 4-Tell, Alatest, Shopzilla, Linkshare. I have hands on experience on open sources and commercial technologies.

Tagged with:
Posted in ecommerce, MongoDB, NoSql
10 comments on “MongoDB – Design of Product Catalog Documents Structure
  1. JP says:

    Hi, great article.

    Could you please explain which information you recommend to save in a RDBMS DB instead of in a NoSQL one? I got confused because, por instance, I would have thought that product inventory transaction should be acid.

    Or, does the info with eventual consistency should be updated in a nosql database?

    Thanks in advance,
    Best regards

    • You can keep transactional data also in NoSql. For example, MongoDB. You can keep order or customer information in MongoDB and make sure you update or insert the entire document at once. Or you can go with Cassandra where you can get eventual consistency.

  2. soengkanel says:

    what is difference id supplied by and supplied by mongodb , could help to explain ?

  3. soengkanel says:

    what is the reason you put “catalog_ref_id” in Inventory Document Structure

  4. Hi, Great series! Looking forward to next article of the series, specially integration between mongo and Elasticsearch.

  5. sravan says:

    Plz can u explain diff b/w MongoDB and other DB?

    • Other DB means? RDBMS?

      If so here are some of the differences.

      RDBMS:

      1. Follows schema. The data will be normalized and will be stored in tables. The schema is defined before putting the data.
      2. Follows ACID principles. Suitable for transnational data
      3. As the data is normalized, requires JOINS to get the data from multiple tables. This impacts the performance.

      MongoDB:

      1. Schemaless. No need to define the data model prior to put the data. The data will be stored as documents
      2. No support for ACID principles. Not suitable to handle transnational data.
      3. As the data is not normolized, no need to use JOINS to get the data. Provides better read performance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

DZone

DZone MVB

Java Code Geeks
Java Code Geeks
%d bloggers like this: