What is MongoDB? How does it work?

  • By Sarika Ganesh Kore
  • August 3, 2023
  • MEAN Stack
What is MongoDB? How does it work?

What is MongoDB? How does it work?

It is a database that provides high-quality performance, availability, and scalability. Following are some of the important concepts about What is MongoDB? How does it work?

Database:- It is a collection of collections. In Mongo we create collections like in other databases we create tables. A mongo server can have multiple databases and a database can have multiple collections.

Collection:- It is a group of documents. It is the same as a table in other databases. A collection will be available in a database. Because of Collections, there is no need for schema. Documents that are available in a collection can have different fields. 

For Free Demo classes Call: 8237077325

Registration Link: Click Here!

Document:- A document in a collection is a set of key-value pairs. Documents have dynamic schema. The meaning of Dynamic schema is that there is no need for the same set of fields or structure of documents in the same collection, and common fields in a  document of a collection can have different types of data.

Note: Join Mern Stack Training in Pune now and embark on an exciting journey into the world of Python programming with MongoDB

Advantages of MongoDB:-

  • No need to write Schema in MongoDB as it uses a document database in which a collection can have different documents. Documents can have different numbers of fields, different content, and different size
  • No need of writing the joins which are difficult to write for beginners.

  MongoDB supports writing dynamic queries on documents using a    

   document-based query language Tuning.

  MongoDB is easy to scale.

  There is no need of Conversion or mapping of application objects to database objects in Mongo DB .

  Mongo DB uses internal memory for storing the working set, so it is very easy and fast to access the data.

For Free Demo classes Call: 8237077325

Registration Link: Click Here!


Why use MongoDB?  

  • We use Mongo DB because of the following reasons
  • Data is stored in JSON format 
  • The index is placed on each and every attribute  
  • Replication of data is possible and high availability of the data  
  • Auto-sharding  
  • Queries written in MongoDB are very Rich queries  
  • Data can be updated very fast  
  • Professional support is given by MongoDB 

Where to Use MongoDB?  

  • When we want to use Big Data  
  • When we need Content Management and Delivery 
  •  Mobile and Social Infrastructure 
  • User Data Management  
  • Data Hub

Creating the Database:-

To create a database in MongoDB we are using “use” command. 

The syntax of use command is as follows:

  • use database-name

By using this command if the mentioned database is not available then it will be created and if it already exists then it will be displayed.

e.g. use employee 

This command will create an employee database.

show dbs command:-

This command show all the databases created in a MongoDB connection.

e.g. show dbs

insert command:-

This command is used to add records in the database. 

e.g. employee.insert({“name”:”AAA”,”email”:”aaa@example.com”,”phone”:”11111”})

Delete database:-

To delete a database use “dropDatabase” command.

e.g. employee.dropDatabase()

For Free Demo classes Call: 8237077325

Registration Link: Click Here!

Creating a Collection:-

“createCollection()” command is used to create a collection. Syntax to create a collection is:-


In this command name parameter specifies the name of the collection and the options parameter specifies the document. The options parameter is not compulsory. Build Modern Web Apps with Mern Stack Course in Pune

“show collections” command will display all the collections created in the database.

“insert” command is used to add a record in the collection. 

If you don’t want to use MongoDB on command prompt or if anyone finds it difficult to write these commands then MongoDB also provides facility of MongoDB compass.

Do visit our channel to learn more about MongoDB: Click Here

MongoDB compass:- 

It is GUI (Graphical User Interface) for using MongoDB effectively and easily. Definitely, beginners will find it easy to use MongoDB.



Sarika Ganesh Kore

Call the Trainer and Book your free demo Class For Mern Stack Call now!!!
| SevenMentor Pvt Ltd.

© Copyright 2021 | SevenMentor Pvt Ltd.

Submit Comment

Your email address will not be published. Required fields are marked *