MongoDB

Madusanka Gajadeera
3 min readMar 22, 2021

What is MongoDB?

MongoDB is a document database that offers the scalability and consistency you need, as well as the querying and indexing you need. In other words, MongoDB is a nonrelational database management system (DBMS) that processes and stores different types of data using customizable documents rather than tables and rows. MongoDB uses collections and documents. These documents, which are formatted in Binary JSON, may store a variety of data and be shared through multiple systems. MongoDB does not only make database management easier for developers, but it also makes cross-platform software and services more scalable.

MongoDB Features

· Replication for better data availability and stability

When the data are stored in a single database, it is vulnerable to a variety of failures, including server crashes, service interruptions, and even hardware failure. Any of these occurrences will make it virtually impossible to access your data. By deploying several servers for disaster recovery and backup, replication helps you to avoid these vulnerabilities.

· Load Balancing

As enterprise cloud applications grow in size and resource demands rise, issues with service availability and reliability will arise. The load balancing sharing mechanism in MongoDB distributes massive data sets through multiple virtual machines at the same time while still ensuring reasonable read and write throughputs.

· Ad hoc database queries

MongoDB allows you to search by field, range query, or regular expression. Relevant fields inside documents can be returned using queries.

· Multilanguage support

MongoDB’s multiple language support is one of its strongest features. MongoDB has been released in several versions and is still being developed, with driver support for common programming languages such as Python, PHP, Ruby, Node.js, C++, Scala, JavaScript, and many others.

Key Components of MongoDB Architecture

· _id — The _id field in a MongoDB document stands for a specific attribute. In a MongoDB text, the _id field uses a unique value. The _id field serves as the primary key for the document.

· Collection — This is a set of documents from MongoDB. A set is the equivalent of a table in some other relational database management system.

· Cursor — This is a reference to the query’s result collection. Clients can retrieve results by iterating over a cursor.

· Database — This is a storage for collections, close to how a container for tables is used in RDMS. On the file system, each database has its own collection of files. Multiple databases can be stored on a MongoDB server.

· Document — A document is a name given to a record in a MongoDB collection. Field names and values can be found in the text.

· Field — In a document, a name-value pair. There are zero or more fields in a document. In relational databases, fields are similar to columns.

Why not use MongoDB

· Joins not supported — MongoDB does not allow joins in the same way as relational databases do. However, one can use joins by manually coding them. Even so, it can slow down execution and have an impact on performance.

· High memory usage — For each value pair, MongoDB stores the key names. There is also data duplication due to the lack of join capability. As a consequence, memory use grows excessively.

· Limited Nesting — More than 100 levels of document nesting are not possible.

· Limited data size — Maximum document size is 16MB.

--

--