Databases, Collections, Documents, BSON, and Schema Basics
Build a strong MongoDB foundation by understanding how data is organized and why document structure matters.
Inside this chapter
- Database, Collection, and Document
- What BSON Means
- Example Document
- Flexible Schema Requires Discipline
Series navigation
Study the chapters in order for the clearest path from MongoDB basics to advanced document modeling and production operations. Use the navigation at the bottom of each page to move through the full series.
Database, Collection, and Document
A MongoDB database contains collections, and each collection stores documents. A document is a structured object made of key-value pairs, nested objects, arrays, and scalar values. This is more flexible than a traditional table-row model and often maps naturally to application objects.
What BSON Means
MongoDB stores documents in BSON, which is a binary representation of JSON-like data. BSON supports additional data types such as dates, object identifiers, and more efficient internal storage handling than plain text JSON.
Example Document
{
_id: ObjectId("661e00000000000000000001"),
fullName: "Neha Sharma",
email: "neha@example.com",
isActive: true,
addresses: [
{
type: "home",
city: "Hyderabad",
postalCode: "500001"
}
]
}
This document shows one reason MongoDB feels natural to many developers: related data can live together inside one record instead of being split across several tables.
Flexible Schema Requires Discipline
Flexible schema does not mean careless design. Teams still need predictable field naming, document size awareness, indexing strategy, validation rules, and migration thinking. Good MongoDB design is intentional, not random.