Table of Contents – MongoDB in Action

Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Preface

Acknowledgments

About this Book

About the Cover Illustration

1. Getting started

Chapter 1. A database for the modern web

1.1. Born in the cloud

1.2. MongoDB’s key features

1.2.1. The document data model

1.2.2. Ad hoc queries

1.2.3. Secondary indexes

1.2.4. Replication

1.2.5. Speed and durability

1.2.6. Scaling

1.3. MongoDB’s core server and tools

1.3.1. The core server

1.3.2. The JavaScript shell

1.3.3. Database drivers

1.3.4. Command-line tools

1.4. Why MongoDB?

1.4.1. MongoDB versus other databases

1.4.2. Use cases and production deployments

1.5. Tips and limitations

1.6. Summary

Chapter 2. MongoDB through the JavaScript shell

2.1. Diving into the MongoDB shell

2.1.1. Starting the shell

2.1.2. Inserts and queries

2.1.3. Updating documents

2.1.4. Deleting data

2.2. Creating and querying with indexes

2.2.1. Creating a large collection

2.2.2. Indexing and explain()

2.3. Basic administration

2.3.1. Getting database information

2.3.2. How commands work

2.4. Getting help

2.5. Summary

Chapter 3. Writing programs using MongoDB

3.1. MongoDB through the Ruby lens

3.1.1. Installing and connecting

3.1.2. Inserting documents in Ruby

3.1.3. Queries and cursors

3.1.4. Updates and deletes

3.1.5. Database commands

3.2. How the drivers work

3.2.1. Object ID generation

3.2.2. BSON

3.2.3. Over the network

3.3. Building a simple application

3.3.1. Setting up

3.3.2. Gathering data

3.3.3. Viewing the archive

3.4. Summary

2. Application development in MongoDB

Chapter 4. Document-oriented data

4.1. Principles of schema design

4.2. Designing an e-commerce data model

4.2.1. Products and categories

4.2.2. Users and orders

4.2.3. Reviews

4.3. Nuts and bolts: on databases, collections, and documents

4.3.1. Databases

4.3.2. Collections

4.3.3. Documents and insertion

4.4. Summary

Chapter 5. Queries and aggregation

5.1. E-commerce queries

5.1.1. Products, categories, and reviews

5.1.2. Users and orders

5.2. MongoDB’s query language

5.2.1. Query selectors

5.2.2. Query options

5.3. Aggregating orders

5.3.1. Grouping reviews by user

5.3.2. Map-reduce for orders by region

5.4. Aggregation in detail

5.4.1. Maxima and minima

5.4.2. Distinct

5.4.3. Group

5.4.4. Map-reduce

5.5. Summary

Chapter 6. Updates, atomic operations, and deletes

6.1. A brief tour of document updates

6.2. E-commerce updates

6.2.1. Products and categories

6.2.2. Reviews

6.2.3. Orders

6.3. Atomic document processing

6.3.1. Order state transitions

6.3.2. Inventory management

6.4. Nuts and bolts: MongoDB updates and deletes

6.4.1. Update types and options

6.4.2. Update operators

6.4.3. The findAndModify command

6.4.4. Deletes

6.4.5. Concurrency, atomicity, and isolation

6.4.6. Update performance notes

6.5. Summary

3. MongoDB mastery

Chapter 7. Indexing and query optimization

7.1. Indexing theory

7.1.1. A thought experiment

7.1.2. Core indexing concepts

7.1.3. B-trees

7.2. Indexing in practice

7.2.1. Index types

7.2.2. Index administration

7.3. Query optimization

7.3.1. Identifying slow queries

7.3.2. Examining slow queries

7.3.3. Query patterns

7.4. Summary

Chapter 8. Replication

8.1. Replication overview

8.1.1. Why replication matters

8.1.2. Replication use cases

8.2. Replica sets

8.2.1. Setup

8.2.2. How replication works

8.2.3. Administration

8.3. Master-slave replication

8.4. Drivers and replication

8.4.1. Connections and failover

8.4.2. Write concern

8.4.3. Read scaling

8.4.4. Tagging

8.5. Summary

Chapter 9. Sharding

9.1. Sharding overview

9.1.1. What sharding is

9.1.2. How sharding works

9.2. A sample shard cluster

9.2.1. Setup

9.2.2. Writing to a sharded cluster

9.3. Querying and indexing a shard cluster

9.3.1. Shard query types

9.3.2. Indexing

9.4. Choosing a shard key

9.4.1. Ineffective shard keys

9.4.2. Ideal shard keys

9.5. Sharding in production

9.5.1. Deployment and configuration

9.5.2. Administration

9.6. Summary

Chapter 10. Deployment and administration

10.1. Deployment

10.1.1. Deployment environment

10.1.2. Server configuration

10.1.3. Data imports and exports

10.1.4. Security

10.2. Monitoring and diagnostics

10.2.1. Logging

10.2.2. Monitoring tools

10.2.3. External monitoring applications

10.2.4. Diagnostic tools (mongosniff, bsondump)

10.3. Maintenance

10.3.1. Backups and recovery

10.3.2. Compaction and repair

10.3.3. Upgrading

10.4. Performance troubleshooting

10.4.1. Check indexes and queries for efficiency

10.4.2. Add RAM

10.4.3. Increase disk performance

10.4.4. Scale horizontally

10.4.5. Seek professional assistance

10.5. Summary

Appendix A. Installation

A.1. Installation

A.1.1. MongoDB on Linux

A.1.2. MongoDB on Mac OS X

A.1.3. MongoDB on Windows

A.1.4. Compiling MongoDB from source

A.1.5. Troubleshooting

A.2. Basic configuration options

A.3. Installing Ruby

A.3.1. Linux and Mac OS X

A.3.2. Windows

Appendix B. Design patterns

B.1. Patterns

B.1.1. Embed versus reference

B.1.2. One-to-many

B.1.3. Many-to-many

B.1.4. Trees

B.1.5. Worker queues

B.1.6. Dynamic attributes

B.1.7. Transactions

B.1.8. Locality and precomputation

B.2. Anti-patterns

B.2.1. Careless indexing

B.2.2. Motley types

B.2.3. Bucket collections

B.2.4. Large, deeply nested documents

B.2.5. One collection per user

B.2.6. Unshardable collections

Appendix C. Binary data and GridFS

C.1. Simple binary storage

C.1.1. Storing a thumbnail

C.1.2. Storing an MD5

C.2. GridFS

C.2.1. GridFS in Ruby

C.2.2. GridFS with mongofiles

Appendix D. MongoDB in PHP, Java, and C++

D.1. PHP

D.1.1. Documents

D.1.2. Connections

D.1.3. Sample program

D.2. Java

D.2.1. Documents

D.2.2. Connections

D.2.3. Sample program

D.3. C++

D.3.1. Documents

D.3.2. Connections

D.3.3. Sample program

Appendix E. Spatial indexing

E.1. Spatial indexing basics

E.2. Advanced queries

E.3. Compound spatial indexes

E.4. Spherical geometry

Index

List of Figures

List of Tables

List of Listings