Cover of Designing Data-Intensive Applications by Martin Kleppmann - Business and Economics Book

From "Designing Data-Intensive Applications"

Author: Martin Kleppmann
Publisher: "O'Reilly Media, Inc."
Year: 2017
Category: Computers

🎧 Free Preview Complete

You've listened to your free 10-minute preview.
Sign up free to continue listening to the full summary.

🎧 Listen to Summary

Free 10-min Preview
0:00
Speed:
10:00 free remaining
Chapter 2: Data Models and Query Languages
Key Insight 3 from this chapter

The Document Model: Design, Benefits, and Challenges

Key Insight

Document databases, including examples like MongoDB, RethinkDB, and CouchDB, embrace a data model where information is stored as self-contained documents, often utilizing JSON for its simplicity compared to XML. This structure is highly appropriate for data exhibiting a tree of one-to-many relationships, where the entire document is typically retrieved and processed in a single operation, such as representing a LinkedIn profile with nested positions, education, and contact information, thereby avoiding the complexities of multi-table relational schemas.

A significant advantage of the document model is enhanced data locality; documents are commonly stored as single, continuous strings (e.g., JSON or BSON), which improves performance when applications frequently access substantial portions of a document. This locality minimizes the need for multiple index lookups and disk seeks that would be required if data were fragmented across various relational tables, and many developers find that the JSON model itself intrinsically reduces the impedance mismatch between application code and the storage layer.

Nevertheless, the document model faces challenges, particularly concerning many-to-many relationships and data consistency. Its support for joins is often weak or absent, forcing application developers to manually emulate joins through multiple database queries, which can lead to increased code complexity and slower performance compared to native database-level joins. Furthermore, documents are generally recommended to be kept small, as updates often involve rewriting the entire document, and as applications evolve and data becomes more interconnected, the document model may become less suitable, making relational or graph models more natural choices.

📚 Continue Your Learning Journey — No Payment Required

Access the complete Designing Data-Intensive Applications summary with audio narration, key takeaways, and actionable insights from Martin Kleppmann.