The MONGODB

Niharika Dhanik
Geek Culture
Published in
4 min readJul 28, 2021

--

Db as in Database. There are various types of data bases available in the market. In this blog, we will be discussing about what makes MongoDB stand out and its related aspects.

What is MongoDB —

MongoDB is a source-available cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. It is developed by MongoDB Inc. MongoDB is an open-source document database and leading NoSQL database. MongoDB is written in C++. It is a document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.

MongoDB provides high availability with replica sets. A replica set consists of two or more copies of the data. Each replica-set member may act in the role of primary or secondary replica at any time. All writes and reads are done on the primary replica by default. Secondary replicas maintain a copy of the data of the primary using built-in replication. When a primary replica fails, the replica set automatically conducts an election process to determine which secondary should become the primary. Secondaries can optionally serve read operations, but that data is only eventually consistent by default.

If the replicated MongoDB deployment only has a single secondary member, a separate daemon called an arbiter must be added to the set. It has a single responsibility, which is to resolve the election of the new primary. As a consequence, an idealized distributed MongoDB deployment requires at least three separate servers, even in the case of just one primary and one secondary.

Working —

MongoDB makes use of records which are made up of documents that contain a data structure composed of field and value pairs. Documents are the basic unit of data in MongoDB. The documents are similar to JavaScript Object Notation but use a variant called Binary JSON (BSON). The benefit of using BSON is that it accommodates more data types. The fields in these documents are similar to the columns in a relational database. Values contained can be a variety of data types, including other documents, arrays and arrays of documents, according to the MongoDB user manual. Documents will also incorporate a primary key as a unique identifier.

Sets of documents are called collections, which function as the equivalent of relational database tables. Collections can contain any type of data, but the restriction is the data in a collection cannot be spread across different databases.

The mongo shell is a standard component of the open source distributions of MongoDB. Once MongoDB is installed, users connect the mongo shell to their running MongoDB instances. The mongo shell acts as an interactive JavaScript interface to MongoDB, which allows users to query and update data, and conduct administrative operations.

A binary representation of JSON-like documents is provided by the BSON document storage and data interchange format. Automatic sharding is another key feature that enables data in a MongoDB collection to be distributed across multiple systems for horizontal scalability, as data volumes and throughput requirements increase.

The NoSQL DBMS uses a single master architecture for data consistency, with secondary databases that maintain copies of the primary database. Operations are automatically replicated to those secondary databases for automatic failover.

Database —

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 —

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 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.

Benefits —

  • Document Oriented Storage (JSON Format)
  • Index on any attribute
  • Replication and high availability
  • Auto-Sharding
  • Rich queries
  • Fast in-place updates
  • Professional support by MongoDB

Applications —

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

Real Life Use Cases —

1. eBay

eBay is a multinational company that provides a platform for the customer to customer sales. It is currently running a large number of projects in MongoDB like merchandising categorization, cloud management, metadata storage, search suggestions.

2. MetLife

MetLife is a leading company in employee benefit programs, annuities, and insurance. There are more than 90 million customers in the Middle East, Europe, Aisa, Latin America, Japan, United States. MetLife is using MongoDB for its advanced customer service application called The Wall.

This application provides a combined view of transactions, policy details, and other details of MetLife Customers. It looks like Wall of Facebook, which takes data from 70 legacy systems and merges it into a single record. It stores 24 Terabytes of data and runs across six servers in two data centers. MetLife is working on a series of Big Data projects where MongoDB-based applications are part of it.

Thank You!!

--

--