Nearby lessons
1 of 22🍃 Introduction to MongoDB
📌 What is MongoDB?
MongoDB is a NoSQL (non-relational) database. It stores data in a JSON-like format called BSON.
A Database is a collection of data stored in a format that can easily be accessed.
🗂 Types of Databases
- SQL Databases: Relational databases using SQL (Structured Query Language)
- NoSQL Databases: Non-relational, schema-flexible databases like MongoDB
📄 Difference Between JSON and BSON
JSON (JavaScript Object Notation):
- String
- Number
- Boolean
- Array
- Object
- Null
BSON (Binary JSON):
- String
- Double
- 32-bit Integer
- 64-bit Integer
- Boolean
- Array
- Object
- Null
- Regular Expression
- Timestamp
- Date
- ObjectId
📊 Comparison: JSON vs BSON
- Format: JSON → Text-based (human-readable), BSON → Binary (not human-readable)
- Size: JSON → Larger due to text overhead, BSON → More compact
- Speed: JSON → Slower to parse and write, BSON → Faster to parse and write
- Usage: JSON → Web APIs and data exchange, BSON → MongoDB and database storage with rich data types
✅ Benefits of MongoDB
- Flexible schema design
- Horizontal scalability through sharding
- High performance for read and write operations
- Powerful query language
- Built-in replication for high availability
- Geospatial data support
- JSON-like BSON data format
- Real-time analytics capability
- Easy integration with big data tools
- Open-source and community-driven