4 min read
•Question 1 of 27easyWhat is MongoDB?
Understanding MongoDB and NoSQL databases.
What You'll Learn
- What MongoDB is
- MongoDB vs SQL databases
- Key features
What is MongoDB?
MongoDB is a document-oriented NoSQL database that stores data in flexible, JSON-like documents called BSON (Binary JSON).
MongoDB vs SQL
| Feature | MongoDB | SQL (MySQL/PostgreSQL) |
|---|---|---|
| Data Model | Documents | Tables/Rows |
| Schema | Flexible | Fixed |
| Scaling | Horizontal | Vertical |
| Joins | Limited ($lookup) | Full support |
| Transactions | Supported | Native |
Key Features
- Flexible Schema - No predefined structure
- Horizontal Scaling - Sharding support
- Rich Queries - Powerful query language
- Indexing - Various index types
- Aggregation - Data processing pipelines
Document Example
code.jsJavaScript
{
_id: ObjectId("507f1f77bcf86cd799439011"),
name: "John Doe",
email: "john@example.com",
age: 30,
address: {
city: "New York",
zip: "10001"
},
hobbies: ["reading", "coding"]
}