Introduction to MongoDB

In this introductory lesson we learn what MongoDB is, the benefits of using MongoDB, the learning difficulty and prerequisites before starting this course.

If you're new to MongoDB, start from the beginning.

What is MongoDB

MongoDB is an open-source, cross platform, document oriented database that provides high performance, high availability, and easy scalability.

MongoDB works on the concept of collections and documents instead of tables, rows and columns like traditional RDB’s (Relational DataBases) such as MySQL.

Let’s take a quick look at how it works.


The database is the container for collections and each database gets its own set of files on the file system. One MongoDB server can, and typically does, contain multiple databases.


A collection is what we call a group of MongoDB documents and is the equivalent of an RDB table. Typically, and even though collections do not enforce a particular schema, all the documents in a collection have a similar, or at least related, purpose.


A document is a set of key:value pairs (like JSON) and have a dynamic schema, which means that documents in the same collection do not neccesarily need to have the same set of fields, or structure.

Let’s see a quick example.

   _id: ObjectId(7af41fd8902g)
   firstName: 'John',
   lastName: 'Doe',
   date-of-birth: new Date("1990-08-07"),
   department: 'Legal',
   children: [
         lastName: 'Doe',
         dateCreated: new Date("2013-05-18")
         firstName:'John Jnr',
         lastName: 'Doe',
         dateCreated: new Date("2017-03-08")

If you’re not familiar with JSON, the example above may not make much sense at the moment but rest assured we will cover everything throughout the course.


While it was designed to work with commodity servers, MongoDB is now used by individuals and enterprizes of all sizes, across many industries.

MongoDB is available for anything from self-hosted free and commercial licenses, to a fully managed cloud database service (Atlas).

Atlas comes in several tiers, ranging from free to dedicated multi-region (global) clusters and can be used on AWS.

What are the benefits of using MongoDB

Many modern applications require big data, flexible deployment and fast feature development. Older RDB’s aren’t specialized towards that, so a different solution was needed.

No-SQL (Not Only SQL) databases like MongoDB solve these problems with ease and provides us with the following benefits.

  • Scalability
  • Performance
  • High Availability
  • Scaling from single server deployments to large, complex multi-site architectures.

And features like:

  • Master-Slave replication. A master can perform Read and Write, and a Slave can copy data from the master with only Read and Backup permissions
  • Data duplication over multiple servers to keep the system up and running in case of hardware failure
  • Automatic load balancing configuration because data is placed in shards
  • Indexing and ad-hoc queries
  • Map reduce and aggregation tools
  • JSON data model with dynamic schemas
  • Using Javascript instead of Procedures
  • File storage of any size without complicating your stack
  • Easy administration in case of failure
  • High performance because it’s written in C++

So basically, with MongoDB we can:

  • Develop Faster
  • Deploy Easier
  • Scale Bigger

Is MongoDB hard to learn

Overall MongoDB is not too complicated which makes it fairly easy to learn. Some concepts like Sharding may prove to be somewhat challenging, especially if you don’t have previous experience with database technologies.


Before we proceed, please note that we make the following assumptions:

  • You know how to install software on whichever operating system you use.
  • You can create and navigate directories and files on your computer.
  • (Optional) You know how to use the command line in your operating system.

While this tutorial course is for beginners with no knowledge of MongoDB, students coming from other SQL or NoSQL technologies may also find it very helpful.

This tutorial course covers many topics of MongoDB, ranging from beginner concepts to advanced.