MongoDB Data Modelling - MongoDB

How data modelling helps in designing schema?

MongoDB data has a flexible schema documents in the same collection. They will have the same set of fields or structure, and common fields in a collection’s documents can hold various types of data.

Some considerations while designing Schema in MongoDB

  • Design your schema based on the user requirements.
  • Merge objects into one document if you are using them together. Else separate them (but make sure that there is no need of joins).
  • Duplicate the data (but limited) as disk space is cheap when compared to compute time.
  • Perform joins while write, not on read.
  • Optimize your schema for most frequent use cases.
  • Perform complex aggregation in the schema.


Assume a client requires a database design for his/her blog/website and observe the differences between RDBMS and MongoDB schema design. Website has below requirements.

  • Every post should have unique title, description and url.
  • Every post may have one or more tags.
  • Every post should have the name of its publisher and total number of likes.
  • Every post has comments given by users along with their name, message, data-time and likes.
  • On each post, there can be zero or more comments.

In RDBMS schema, design for above requirements will have minimum three tables.


While in MongoDB schema, design will have one collection post and below structure

Therefore while showing the data in RDBMS, you have to join three tables and in MongoDB, data will be shown from one collection only.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

MongoDB Topics