Introduction to MongoDB
MongoDB is a NoSQL (Non-Relational) database that stores data in a flexible, document-oriented format called BSON (Binary JSON). It is widely used for modern applications that require scalability, flexibility, and high performance.
π§© Key Features of MongoDB
- Document-Oriented Storage
Data is stored in documents (similar to JSON objects).
Each document contains keyβvalue pairs, making it more flexible than traditional row-column structures.
- Schema-less
Unlike SQL databases, MongoDB does not require a fixed schema.
Documents in the same collection can have different fields and structures.
- Collections and Databases
A database contains multiple collections.
A collection contains multiple documents.
(Equivalent of table β collection, and row β document in SQL.)
- Scalability
Supports horizontal scaling using sharding, allowing data to be distributed across multiple servers.
- Replication and High Availability
MongoDB uses replica sets for automatic failover and data redundancy.
- Rich Query Language
Supports powerful queries, filtering, aggregation, and indexing for performance optimization.
βοΈ Basic MongoDB Structure
SQL Term MongoDB Equivalent
Database Database
Table Collection
Row Document
Column Field
Primary Key _id field (auto-generated)
π Advantages of MongoDB
Flexible data model
High performance and scalability
Easy integration with programming languages (like Python, Java, Node.js, etc.)
Ideal for big data, real-time analytics, and cloud applications
Schema (Collection: students)
Each student document should follow the structure below:
{
"student_id": "S001",
"name": "Santhosh",
"age": 20,
"department": "CSBS",
"year": 2,
"cgpa": 9
}
1οΈβ£ Create (Insert)
Insert at least 5 student records into the students collection.
2οΈβ£ Read (Query)
Display all student records.
Find all students with CGPA > 8.
Find students belonging to the Computer Science department.
3οΈβ£ Update
Update the CGPA of a specific student.
Increase the year of study for all 3rd year students by 1.
4οΈβ£ Delete
Delete one student record by student_id.
Delete all students having CGPA < 7.5.
Deliverables
MongoDB queries (insert, find, update, delete.
Conclusion
MongoDB is a powerful database solution designed for handling large volumes of unstructured or semi-structured data efficiently. Its flexibility, scalability, and ease of use make it a popular choice for modern web and mobile applications.







Top comments (0)