MongoDB Tutorial

In this MongoDB Tutorial, we shall learn the basics of MongoDB, different CRUD Operations available for MongoDB Documents, Collections and Databases, and integrating MongoDB to applications developed using programming languages like Java, Python, Kotlin, Java Script, etc. We shall also take you through different MongoDB examples for better understanding the syntax.


There is nothing in particular that you should know before you get started with this series of MongoDB Tutorials. But it could help, if you know a little bit about the concepts of Relational Databases and NoSQL Databases.

What is MongoDB

MongoDB is a database program that is

  • Free – You don’t have to pay a price to use it in your application.
  • Open Source – The source is open and open source community contributes to the development of MongoDB database program.
  • Cross Platform – MongoDB build on a platform (say Linux) works on other platforms(Windows, MacOS, etc.) as well without any modification to the code.
  • Document Oriented – MongoDB stores records in form of JSON like documents. There are many advantages in doing so. A notable advantage is that adding new features(columns in relational database) to the database requires no hassle.
  • NoSQL (Not only SQL) – MongoDB uses document based databases where each document is a key with complex value. The document value can contain multiple key-value pairs.

MongoDB is written in C++ language.

How MongoDB is better than Relational Databases

MongoDB packs the advantages of NoSQL. NoSQL database concepts were developed to make the applications more modern and fast. NoSQL databases overcome the disadvantages of SQL.

  • Structured Data – MongoDB can handle structured data(like a spread-sheet or table), semi structured data and unstructured data (data with no rules, examples are multimedia content).
  • Agile Development – All the NoSQL features of MongoDB makes it perfect fit for Agile methodology for developing applications. Modern applications are designed to have fewer development time and quick updates to the ever ending requirements.
  • Scalability – MongoDB is horizontally scalable and thus can respond to the increasing application requirements with less cost.

Some other features of MongoDB

  • Replication – You can setup replication of data between MongoDB instances. When an instance goes down, other instance can handle the requests with same data available.
  • MapReduce – You can apply MapReduce algorithm on the MongoDB Collections to pull out some useful reports.

When to use MongoDB in your application ?

You might be wondering, with such a wide variety of databases available out there, why should you select MongoDB or what project requirements demand the use of MongoDB.

Try to answer the following questions, and if you get an YES for most of them, choose MongoDB.

  1. Is your data structured or not ? Structured !
  2. Does your application need scalability? horizontally in particular !
  3. Do you want your schema design to be flexible ?
  4. Does you data objects move around the application as JSON ?
  5. You do not require JOINS on different collections ?

Applications of MongoDB

Following are some of the Application of MongoDB that are known in production :

  1. Analyzing Application Logs MongoDB’s schema-less feature makes it a best fit for analyzing application logs where record schema may change from time to time.
  2. Automatic Purging Capped Collection of MongoDB helps to purge old records automatically.

Index – MongoDB Tutorial

With a brief introduction tour to MongoDB, let us dive into working with MongoDB.

This series of MongoDB Tutorials are provided with lucid explanation and well formed examples.