MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++. This tutorial will give you the great understanding of MongoDB concepts needed to create and deploy a highly scalable and performance-oriented database.

Overview

MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on the concept of collection and document.

Database

The database is a physical container for collections. Each database gets its own set of files on the file system. A single MongoDB server typically has multiple databases.

Collection

A collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collection exists within a single database. Collections do not enforce a schema. Documents within a collection can have different fields. Typically, all documents in a collection are of similar or related purpose.

Document

A document is a set of key-value pairs. Documents have the dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection’s documents may hold different types of data.

Key Features

High Performance

MongoDB provides high-performance data persistence. In particular,

  • Support for embedded data models reduces I/O activity on the database system.
  • Indexes support faster queries and can include keys from embedded documents and arrays.

Rich Query Language

MongoDB supports a rich query language to support read and write operations (CRUD) as well as:

  • Data Aggregation
  • Text Search and Geospatial Queries.

High Availability

MongoDB’s replication facility, called a replica set, provides:

  • automatic failover and
  • data redundancy.

A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability.

Horizontal Scalability

MongoDB provides horizontal scalability as part of its core functionality:

  • Sharding distributes data across a cluster of machines.
  • Starting in 3.4, MongoDB supports creating zones of data based on the shard key. In a balanced cluster, MongoDB directs reads and writes covered by a zone only to those shards inside the zone. See the Zones manual page for more information.
  • Support for Multiple Storage Engines
  • MongoDB supports multiple storage engines:
  • WiredTiger Storage Engine (including support for Encryption at Rest)
  • In-Memory Storage Engine
  • MMAPv1 Storage Engine (Deprecated in MongoDB 4.0)

In addition, MongoDB provides pluggable storage engine API that allows third parties to develop storage engines for MongoDB.

MongoDB – Advantages

Any relational database has a typical schema design that shows the number of tables and the relationship between these tables. While in MongoDB, there is no concept of relationship.

Advantages of MongoDB over RDBMS

  • Schema-less − MongoDB is a document database in which one collection holds different documents. The number of fields, content, and size of the document can differ from one document to another.
  • Structure of a single object is clear.
  • No complex joins.
  • Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that’s nearly as powerful as SQL.
  • Tuning.
  • Ease of scale-out − MongoDB is easy to scale.
  • Conversion/mapping of application objects to database objects not needed.
  • Uses internal memory for storing the (windowed) working set, enabling faster access to data.

Why Use MongoDB?

  • Document Oriented Storage − Data is stored in the form of JSON style documents.
  • Index on any attribute
  • Replication and high availability
  • Auto-sharding
  • Rich queries
  • Fast in-place updates
  • Professional support by MongoDB

Where to Use MongoDB?

  • Big Data
  • Content Management and Delivery
  • Mobile and Social Infrastructure
  • User Data Management
  • Data Hub

Tell us about a new Kubernetes application

Newsletter

Never miss a thing! Sign up for our newsletter to stay updated.

About

Discover and learn about everything Kubernetes

Navigation