In MongoDB, data has a flexible schema. It is totally different from SQL database where you had to determine and declare a table's schema before inserting data. MongoDB collections do not enforce document structure.
The main challenge in data modeling is balancing the need of the application, the performance characteristics of the database engine, and the data retrieval patterns.
For example:
let us take an example of a client who needs a database design for his website. His website has the following requirements:
Every post is distinct (contains unique title, description and url).
Every post can have one or more tags.
Every post has the name of its publisher and total number of likes.
Each post can have zero or more comments and the comments must contain user name, message, data-time and likes.
For the above requirement, a minimum of three tables are required in RDBMS.
But in MongoDB, schema design will have one collection post and has the following structure: