Chapter 1
In this article, we will discuss the design and process of installing MongoDB to implement the structure of the data and related configuration of a MongoDB database.
If we talk about the core of most large and scalable applications or services, the best solutions always are the high-performance data storage solutions. So, every good application always requires the proper process or mechanism to store and retrieve data with accuracy, speed, and reliability. So, for the solution to this problem, there are several storage solutions available in the market which we can use. Out of them, the three main components are –
Direct file systems in files
RDBMS or Relational Database
No SQL Database
The below sections describe the basic concept of NoSQL and MongoDB.
What is No-SQL Database?
The actual meaning of NoSQL database is Not Only SQL. It means that NoSQL databases are actually an alternative to SQL Databases and can perform all types of query operations like Microsoft SQL Server. NoSQL contains all databases which are not a part of the traditional database management systems (RDBMS). The main objectives behind the NoSQL database are basically simple design, both horizontal and vertical scaling, and also easy control over the available data. NoSQL database breaks the traditional structure of the relational database for the first time and also provide developers such an opportunity where they can implement models just like data as per their programming requirements. This means that NoSQL databases can be implemented and designed in such a way that traditional relational databases could not be structured.
In today’s development world, there are several different NoSQL database technologies, like HBase Column structure, the Redis key/value structure etc. In this article series, we will discuss MongoDB since it is the most popular and well supported NoSQL database currently available. There are four types of NoSQL databases available currently:
Document Databases
Document databases always apply a document-oriented approach to store data. The main idea behind this type of database is that all data for a single entity needs to be stored as a document and all documents can be stored together within a collection. This document can store the sub-document data, which in RDBMS are typically stored as an encoded string or within a separate table. Each and every document can be accessed by a unique key.Key-Value Database
In the NoSQL database category, key-value storage is the simplest one. These databases store the data in a schemeless way. A key can point to any type of data, like an object, string or any other types of data. The main advantages of these databases is they are easy to implement and add data into. Data can be fetched from these databases with the help of a key value. But the main drawback is that we can’t find any elements based on the stored value. We always need to find data on the basis of the key name.Column Store Database
These types of databases store data in columns within a keyspace. The key space is always defined on a unique name, value, and a timestamp. This is quite similar to key-value databases.Graph Store Database
These types of databases are mainly designed for data that can be easily represented as a graph data. This means that data are interconnected with an undetermined number of data relations between them like family and social relations, etc.
What is Document Database?
A document database is a special kind of database which is based on the principle of dealing with data or documents rather than strictly defined tables of information. These types of databases always play an important role in aggregating data from documents and getting them into a searchable, organized form.
In the document-oriented database, the concept of Row is replaced with the more flexible data model called documents. In this type, the database allows embedded documents and arrays in such a way that the document-oriented approach represents the more complex hierarchical data relationships in a single record. Basically, the document database always supports the semi-structured data model. For example, suppose one document has two names, one address, and a list of the ages of a home’s occupants. A second document might have four names, two addresses, and no age information. A document-oriented database will take the data in both and store them according to type, able to handle non-fixed length data sets.
Advantages of Document Database over RDBMS
The main advantages of document-based databases are,
It can store large volumes of structured, semi-structured, or unstructured data
Each document in a collection is independent with respect to the other documents in the same collections
The logic of the application is easy to write since there is no need for conversation of objects between database and applications like SQL database.
It supports strong indexing features. For this reason, searching of the data is very fast.
Key Features of MongoDB
MongoDB is not only a general-purpose database which can perform only insert, update and delete data within it. Besides these, there are several important features which make the MongoDB one of the most popular and enriched databases in the world of NoSQL databases. Some of the features are as below,
MongoDB supports JSON data models with dynamic schemas.
In MongoDB, we can perform a search on any field or any range query and also can use a regular expression for searching the data
MongoDB supports secondary indexes which allow us to search a variety of data in a very small timespan. It also provides us with different types of indexes like unique index, compound index, geospatial index etc.
MongoDB supports aggregation pipeline which helps us to build complex aggregations to optimize the database
MongoDB supports Master-Slave replication
MongoDB support automatic load balancing features.
MongoDB supports auto-sharding for horizontal scaling.
MongoDB can store any type of file which can be any size without affecting our stack
MongoDB basically use JavaScript objects in place of the procedure.
MongoDB supports special collection type like TTL (Time-To-Live) for data storage which expires at a certain time.

