DEV Community

loading...
Cover image for Getting started with MongoDB

Getting started with MongoDB

Nishiki Asumi Yapa
Software Engineering Undergraduate | Former SE Development Intern at London Stock Exchange Group (LSEG)
・2 min read

Before we start, let’s discover what is MongoDB and its features.

What is MongoDB?

MongoDB is document-oriented, as known as the non-relational database used for the storage of high volume data.

What are the differences between relational and non-relational?

MongoDB is based on Binary JSON (BSON). And it is a simple query language which combines rich and document-based queries. The MongoDB data contains a flexible schema. Unlike in SQL databases, where you must have the schema of a table declared before inserting data, the collections of MongoDB do not enforce document structure. That kind of flexibility is what makes MongoDB so strong.

The environments on MongoDB are very scalable. Companies worldwide have identified clusters with some running 100 + nodes in the database with around millions of documents.

Why MongoDB?

Since MongoDB is a NoSQL style database, it stores the data in records, rather than having data in a relational type format. That makes MongoDB very versatile and adaptable to the situation and requirements of the real business world. And also Indexes can be created to improve search performance within MongoDB. It is possible to index any area in a MongoDB database.

Below are some of MongoDB’s main term differences with RDBMS.

Procedure for installing MongoDB on windows

  1. download MongoDB Community Edition

[Link] https://www.mongodb.com/download-center/community?jmp=docs

  • When you select a version, you can select ‘MongoDB server 4.2’ since it is the latest one.

  • In the package drop down you have to select ‘MSI’.

  1. Run the previously downloaded MongoDB installer.

  2. Follow the MongoDB community edition installation wizard.

For more information on MongoDB installation:

[Link] https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

Crud operations in MongoDB

Insert

There are multiple ways to insert data into the database

  • Inserting a single document

db.collection.insertOne()

  • Inserting multiple documents

db.collection.insertmany()

  • Inserting single/multiple documents

db.collection.insert()

Update

Ways to update data in the database

  • db.collection.updateOne(, , )
  • db.collection.updateMany(, , )
  • db.collection.replaceOne(, , )

Delete

Ways to delete data in the database

  • db.collection.deleteMany()
  • db.collection.deleteOne()

You can find more information on MongoDB:

[Link] https://docs.mongodb.com/manual/

Discussion (0)

Forem Open with the Forem app