A document database stores persistent data as documents rather than requiring every record to fit a predefined table structure. In MongoDB, documents can have different fields and data types. This makes it practical to store application objects with little transformation and to change their structure as an application evolves. section 1.1
Design documents around how the application reads and writes data. Keeping related data together can reduce the need for joins and lower retrieval costs. The trade-off is not that schemas cease to matter: you still need to decide which data belongs together based on the workload. A relational database may be a better fit when complex, precise transactions and strict data integrity dominate. section 5.1.1 section 1.1
Listing 1.1 A MongoDB document with arrays and nested documents
{
"_id": 1,
"title": "MongoDB 8.0 in Action",
"publisher": "Manning Publications",
"status": "Available",
"focusAreas": [
"MongoDB Database System",
"Atlas Platform"
],
"publicationYear": 2025,
"additionalDetails": {
"embeddedDocument": {
"description": "A comprehensive guide to mastering
MongoDB 8.0, including working with the Atlas
Platform and learning the latest features"
}
}
}
This MongoDB document has ordinary fields, an array, and nested documents. Its structure illustrates how related information can be held in one record. section 1.1
Read, change, and remove documents
In the MongoDB shell, `db.books.find({ "title": "MongoDB 8.0 in Action" })` finds a matching document. Use `db.books.updateOne({ "title": "MongoDB 8.0 in Action" }, { $set: { "publisher": "Manning Publications Co" } })` to change one field, or `db.books.deleteMany({ "status": "out of print" })` to remove matching documents. Check a `deleteMany` filter carefully: it applies to every match. section 1.1
Table 5.1 The workload necessary for an application
| Action |
Type |
Information |
Frequency |
Priority |
| Add new route. |
Write |
|
150 per day |
High |
| Search flight routes. |
Read |
|
22,000 per day |
High |
| Update route details. |
Write |
|
100 per day |
Medium |
| Check route information. |
Read |
|
40,000 per day |
High |
The airline-route workload lists each action, its read or write type, fields, frequency, and priority. Use those access patterns to guide document design; frequent route lookups deserve particular attention. section 5.1.1
MongoDB stores documents as BSON, which extends JSON with types including dates and binary data. Its document model also supports scaling out through sharding, which distributes data across servers. MongoDB Atlas offers a managed deployment option. These capabilities do not replace the first design step: identify the queries the application must serve. section 1.6 section 5.1.1


