2. Topics
-What Is MongoDB
-Why Use MongoDB
-When To Use MongoDB
-How MongoDB is different from RDBMS
-How It Works
-How To Use MongoDB
-Pros & Cons Of MongoDB
3. What is MongoDB
• MongoDB is an open-source document-oriented database.
• It is designed to store a large scale of data.
• It also allows you to work with data very efficiently.
• It is categorized under the NoSQL (Not only SQL) database because
the storage and retrieval of data are not in the form of tables.
How it works ?
4. Why Use MongoDB?
How it works ?
• MongoDB is built on a scale-out architecture that has become popular
with developers of all kinds for developing scalable applications with
evolving data schemas.
• As a document database, MongoDB makes it easy for developers to
store structured or unstructured data.
• It uses a JSON-like format to store documents. This format directly
maps to native objects in most modern programming languages,
• It can also handle high volume and can scale both vertically or
horizontally to accommodate large data loads.
5. When To Use MongoDB?
How it works ?
• Storing large volumes of data without structure.
• NoSQL databases like are a good choice when your data is document-
centric and doesn’t fit well into the schema of a relational database,
6. How mongoDB is different from RDBMS
MongoDB. RDBMS.
It is a non-relational and document-oriented
database.
It is a relational database.
It is suitable for hierarchical data storage. It is not suitable for hierarchical data storage.
It has a dynamic schema. It has a predefined schema.
In terms of performance, it is much faster than
RDBMS.
In terms of performance, it is slower than
MongoDB.
7. How it works ?
• Now, we will see how actually thing happens behind the scene.
• As we know that MongoDB is a database server , and the data is
stored in these databases.
• Because of its NoSQL database, the data is stored in the collections
and documents. the database, collection, and documents are
related to each other as shown below:
8. • Collections just like the MYSQL database tables. You are allowed to create
multiple databases and multiple collections.
• Now inside of the collection we have Documents. These documents contain the
data we want to store in the database & a single collection can contain multiple
documents & schema-less means it is not necessary that one document is similar
to another.
• The documents are created using the fields. Fields are key-value pairs in the
documents, it is just like columns in the relation database. The value of the fields
can be of any BSON data types like double, string, boolean, etc.
• Here, BSON stands for Binary representation of JSON documents.
• Or we can Say the MongoDB server converts the JSON data into a binary form
that is known as BSON
• Why BSON-:
• MongoDB uses BSON to offer powerful indexing and querying features
• JSON has a specific set of data types—string, boolean, number for numeric data
types, array, object, and null. Unlike JSON, BSON offers additional data types
such as bindata for binary data, decimal128 for numeric.
13. To Use MongoDB With Spring Boot Application
MongoRepository -:
MongoRepository is an interface provided by Spring Data in the
package org.springframework.data.mongodb.repository. MongoRepository extends
the PagingAndSortingRepository and QueryByExampleExecutor interfaces that further extend
the CrudRepository interface. MongoRepository provides all the necessary methods which help
to create a CRUD application and it also supports the custom derived query methods.
Dependency Required-:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
14. Pros & Cons Of MongoDB
How it works ?
• Pros of MongoDB :
• It is a schema-less NoSQL database. You need not to design the schema of the database when you
are working with MongoDB.
• It does not support join operation.
• It provides great flexibility to the fields in the documents.
• It contains heterogeneous data.
• It provides high performance, availability, scalability.
• It is a document oriented database and the data is stored in BSON documents.
• Cons of MongoDB :
• It uses high memory for data storage.
• It doesn’t support mapping between data.
• You are not allowed to store more than 16MB data in the documents.
• The nesting of data in BSON is also limited you are not allowed to nest data more than 100 levels.