Preface
Part I.Design Patterns
1.To EmbedOrReference
Relational Data Modeling and Normalization
What Is a Normal Form,Anyway?
So What''s the Problem?
Denormalizing for Performance
MongoDB:Wh0 Needs Normalization.Anyway?
MongoDB Document Format
Embedding for Locality
Embedding for Atomicity and Isolation
Referencing for Flexibilitv
Referencing for Potentially High--Arity Relationships
Many-to-Many Relationships
Conclusion
2.PolymorphicSchemas
Polymorphic Schemas to SuppoObjectOriented Programming
Polymorphic Schemas Enable Schema Evolution
StorageIn-Efficiency ofBSON
Polymorphic Schemas SuppoSemiStructured Domain Data
Conclusion
3.MimickingTransactional Behavior
The Relational Approach to Consistency
Compound Documents
Using Complex Updates
Optimistic Update with Compensation
Conclusion
Partll.UseCases
4.OperationalIntelligence
Storing Log Data
Solution 0verview
Schema Design
Operations
Sharding Concerns
Managing Event Data Growth
PreAggregated Reports
Solution 0verview
Schema Design
Operations
Sharding Concerns
Hierarchical Aggregation
Solution Overview
Schema Design
MapReduce
Operations
Sharding Concerns
5.Ecommetce
Product Catalog
Solution Overview
Operations
Sharding Concerns
Category Hierarchy
Solution Overview
Schema Design
Operations
Sharding Concerns
Inventory Management
Solution 0verview
Schema
Operations
Sharding Concerns
6.ContentManagementSystems
Metadata and Asset Management
Solution Overview
Schema Design
Operations
Sharding Concerns
Storing Comments
Solution 0verview
Approach:One Document per Comment
Approach:Embedding All Comments
Approach:Hybrid Schema Design
Sharding Concerns
7.OnlineAdvertising Networks
Solution Overview
Design 1:Basic Ad Serving
Schema Design
Operation:Choose an Ad to Serve
Operation:Make an Ad Campaign Inactive
Sharding Concerns
Design 2:Adding Frequency Capping
Schema Design
Operation:Choose an Ad to Serve
Sharding
Design 3:Keyword Targeting
Schema Design
Operation:Choose a Group ofAds to Serve
8.SociaI Networking
Solution Overview
Schema Design
Independent Collections
Dependent Collections
Operations
Viewing a News Feed or WaU Posts
Commenting on a Post
Creating a New Post
Maintaining the Social Graph
Sharding
9.OnlineGaminq.
Solution Overview
Schema Design
Character Schema
Rem Schema
Locion Schema
Operations
Load Character Data from MongoDB
Extract Armor and Weapon Data for Display
Extract Character Attributes,Inventorand Room Information for Display
PickUp anItemfrom aRoom
Remove an Item from a Container
Move the Character to a Different Room
Buy an Item
Sharding
Afterword
Index