Open In App

Create Database using MongoDB Compass

Last Updated : 04 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

MongoDB is a database that utilizes a document-oriented approach to store data. It internally stores data in BSON format, but as developers, we can interact with MongoDB using JSON for sending and receiving data. MongoDB handles the conversion between JSON and BSON automatically. In contrast, traditional relational databases like MySQL store data in tables. Each table represents a real-life entity, and within a table, there are multiple rows that correspond to individual data records. The columns in a table represent the properties of the entity.

In MongoDB, data is stored in the form of documents, which are similar to JSON objects. Collections in MongoDB serve the purpose of tables in relational databases. Essentially, collections are groups of JSON-like documents. Each individual record in a collection is referred to as a document, which can be seen as the equivalent of a row in a relational database.

A document in MongoDB is essentially a JSON object (internally stored as BSON) that contains multiple key-value pairs. Each key within the JSON represents a property of the entity. Thus, in MongoDB, the key in a key-value pair can be considered equivalent to a column in a relational database.

Example of a Document

The Document contains the information of a STUDENT in JSON format.

{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "CS"
}

Example of a Collection

The Bunch of documents creates a collection.

[
{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "CS"
},
{
"Name" : "Vivek",
"Age" : 19,
"Gender" : "Male",
"Dept" : "BBA"
},
{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "HIS"
},
{
"Name" : "Rohit",
"Age" : 21,
"Gender" : "Male",
"Dept" : "CS"
}
]

MongoDB Compass

MongoDB Compass is a GUI interface for MongoDB. It allows users to analyze the content of their stored data without any prior knowledge of MongoDB query syntax.

For Create Database using MongoDB Compass. First of all, Need to Install MongoDB Compass Application on the system.

Steps for Install MongoDBCompass

Step 1: Download the MongoDB Compass exe package from MongoDB official Website.

Step 2: After Redirect to that page Click on “Download” Button.

9.png

Step 3: After Successful Download, Open the downloaded file by double click on Downloaded File.

Step 4: After Double Click on the Downloaded File. MongoDB Compass Start Installing in your system. It takes a few seconds to install.

10.png

Step 5: After Successful Install it will be automatically opened in your system.

11.png

From the Above Steps, we have learned how to Install MongoDB Compass. Now Lets, Learn How to Create a Database using MongoDB Compass.

Steps to create a new Database using MongoDB Compass

Step 1: Simply Open MongoDB Compass on your system.

Step 2: After Successfully Opening, Click on “Connect” Button.

1.png

Step 3: After Click On “Connect” Button, Click on plus (+) Sign.

2.png

Step 4: After Clicking on Plus (+) icon, a popup will appear in which you have to give Database Name and Collection Name.

3.png

Step 5: Here you can give any Database Name and Collection Name as per your Choice. Here taking the Database name “GFG” and Collection Name “college”.

Step 6: After that Click on the “Create Database” Button.

4.png

From the above Steps Database of the name “GFG” will be Created.

Step 7: After that, click on “ADD DATA” and select the “Insert document” option.

5.png

Step 8: After Clicking on “Insert document” a new popup appear.

6.png

Step 9: Here paste or write the bunch of documents that is Collection and After after that Click on the “Insert” Button.

Databased have been created using MongoDB compass.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads