Create Database using MongoDB Compass (original) (raw)

MongoDB is a popular **NoSQL database that uses a document-oriented storage model, differing from traditional relational databases. Instead of storing data in tables with rows and columns, MongoDB stores data as documents in BSON format. **MongoDB Compass is a graphical user interface (GUI) that allows users to interact with MongoDB databases easily, without requiring advanced knowledge of MongoDB query syntax.

In this article, We will learn about the process of creating a MongoDB database using **MongoDB Compass, from installation to managing our first database. By the end, we'll be able to create databases and collections and insert documents into MongoDB with ease.

**What is MongoDB Compass?

**MongoDB Compass is a free, powerful GUI for MongoDB. It simplifies managing your MongoDB data by providing an intuitive interface to interact with our database. Using MongoDB Compass, we can create, query, update, and delete documents without the need for complex MongoDB commands. It's particularly useful for those who prefer working with a graphical interface instead of writing queries manually.

Understanding MongoDB Document-Oriented Storage vs Traditional Relational Databases

**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"
}
]

**How to install 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 MongoDB Compass

**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 Database Using MongoDB Database

Now that MongoDB Compass is installed, follow these steps to create your first database and collection:

**Step 1: Simply Open MongoDB Compass on your system.

**Step 2: After Successfully Opening, click the **Connect button to connect to your MongoDB server.

**Step 3: If you're using **MongoDB Atlas, copy the connection string from the Atlas dashboard and paste it into the Compass connection field. If we're working with a local MongoDB instance, use the default connection URI: mongodb://localhost:27017.

1.png

**Step 4: After connecting to MongoDB, click the **plus (+) sign next to **Databases on the left sidebar.

2.png

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

3.png

**Step 6: Here we can give any Database Name and Collection Name as per your Choice. Here taking the Database name "GFG" and Collection Name "college".

**Step 7: After that Click on the "Create Database" Button.

4.png

From the above Steps Database of the name "**GFG" will be Created.

**Step 8: After that, click on "ADD DATA" and select the "Insert document" option.

5.png

**Step 9: After Clicking on "Insert document" a new popup appear.

6.png

**Step 10: Here paste or write the bunch of documents that is Collection and After after that Click on the "Insert" Button.

Database have been created using MongoDB compass.

Conclusion

Overall, MongoDB's document-oriented storage offers a flexible and scalable alternative to traditional **relational databases. By using JSON-like documents and collections, MongoDB simplifies the management of complex data structures and offers automatic conversion between JSON and BSON. Tools like MongoDB Compass further enhance user experience by providing a graphical interface for managing and interacting with MongoDB databases.