Guide To Model Database For Blog In MongoDB

By bhagwatchouhan
Guide To Model Database For Blog In MongoDB

This tutorial provides complete steps to design a database schema to manage the users, blog posts, post metadata, post comments, post categories, and post tags. It can be further used to develop a blogging website or mobile application.

 

Notes: We will continue with the MongoDB, MongoDB Shell, and Compass installation as mentioned in How To Install MongoDB on Windows, How To Install MongoDB on Ubuntu Desktop, and How To Install MongoDB on Ubuntu. A similar guide is also available to design the relational database schema in MySQL - Guide To Design Database For Blog Management In MySQL.

Since MongoDB uses the JSON documents to store the data, we can store the entire data of a post in the same document. To avoid data duplication, we will use separate Collection to store the documents of Users, Blog Posts, Categories, and Tags. The Blog Post document will be used to store the post meta, post comments, categories mappings, and tag mappings. If we compare it with the schema design in MySQL, it will have 4 Collections as compared to 8 tables.

The rest of the tutorial will discuss about the document structure of Users, Blog Posts, Categories, and Tags.

Users Collection

Categories Collection

Tags Collection

Blog Posts Collection


Summary

 

 

share on :

Profile picture for user bhagwatchouhan
bhagwatchouhan