Brief Introduction to MongoDB

Salitha Ekanayaka
4 min readFeb 23, 2021
Source:Dev Tutorials

MongoDB is an open-source, non-structured (no SQL) database . This is used to store data and persists in your application. Due to its speed, ease of use, and scalability it became more popular. In Mern Stack Projects MongoDB act as the database from that projects. Similar to SQL databases we can use MongoDB to Insert, Find, Retrieve data, Update and Delete data

Meaning of no SQL databases

This means they are non-relational databases. This provides a flexible schema for the storage and retrieval of data beyond the formation of tables in SQL databases

Process of MongoDB in Mern Stack

In frontend (Reactjs) data are stored in JSON documents are sent to the Backend (ExpressJs) server they can be processed stored directly in the MongoDB database. And when we want to retrieve in a similar way we can get JSON objects and display them in frontend

Source: MongoDB

Advantages of MongoDB

  1. In MongoDB, we have no SQL used so we don’t need to interconnect tables using different statements
  2. We can access MongoDB using any language and in data structures that are native to that language
  3. When we clearing the mistakes and design a process MongoDB will not disrupt that operation at anytime
  4. powerful querying and analytics
  5. Easy horizontal scale-out

Popular Companies that use MongoDB

  1. Google
  2. CISCO
  3. Adobe
  4. Pearson
  5. Barclays etc

Cluster controls

This the database management system that allows us to step up and work with MongoDB. Under a Cluster, we have Databases, Collections, Documents, and Fields

Source: includehelp

Collection

A collection is more or less similar to a Structural table (SQL DataBase table). But there’s a bit different from the Structural table. That is inside Collections there are documents as entries. We can create any number of collections inside a database

Documents

Documents are similar to raws in SQL databases. When creating we have to use JSON format. We can create any number of documents inside a collection and there can be different values inside a document

Inside a document, we can store a key-value pair and other attributes with their values

Documents are written inside the curly brackets and Documents don’t follow any order

Source:Studio 3T

Creating a MongoDB database

First, we have to create an account. (If we need we even can log in with google authentication also). When we create an account we can use the free version or paid version

Source: mongodb

Then we go for a dashboard. Under that dashboard, we have to press “Create a new cluster button” to create a new cluster

After filling respective fields and by entering a new cluster name we can a new cluster (For initial stages we can create free clusters but after creating more than 3 or 4 clusters we have to pay some value to create clusters

Then we navigate to the same dashboard with a cluster created

Source: MongoDB

When we press the collection button we navigate to the collection interface

Source: MongoDB Atlas

By pressing the “Create Database” button and by entering a database name and a collection name we can create a database

Conclusion

In this article, I briefly explain what is MongoDB, the Advantages of MongoDB, MongoDB in Mern Stack, Collection, Document and how to create a database in MongoDB

For more information, you can refer below links

MongoDB official site

MongoDB

--

--