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

Create Database using MongoDB Compass

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.

Similar Reads

Example of a Document

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

Example of a Collection

The Bunch of documents creates a collection....

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....