© 2010, OpenThink Labs. All Rights Reserved
MongoDB
The Definitive Guide
Wildan Maulana
wildan.m@openthinklabs.com
© 2010, OpenThink Labs. All Rights Reserved
1. Introduction
● A Rich Data Model
● Easy Scaling
● Tons of Features…
● …Without Sacrificing Speed
● Simple Administration
● But Wait, That’s Not All…
© 2010, OpenThink Labs. All Rights Reserved
2. Getting Started
● Documents
● Collections
● Schema-Free
● Naming
● Databases
● Getting and Starting MongoDB
● MongoDB Shell
● Running the Shell
● A MongoDB Client
● Basic Operations with the Shell
● Tips for Using the Shell
● Data Types
● Basic Data Types
● Numbers
● Dates
● Arrays
● Embedded Documents
● _id and ObjectIds
© 2010, OpenThink Labs. All Rights Reserved
3. Creating, Updating, and Deleting
Documents
● Inserting and Saving Documents
● Batch Insert
● Inserts: Internals and Implications
●
Removing Documents
● Remove Speed
● Updating Documents
● Document Replacement
● Using Modifiers
● Upserts
● Updating Multiple Documents
● Returning Updated Documents
● The Fastest Write This
Side of Mississippi
● Safe Operation
● Catching “Normal”
Errors
● Requests and
Connections
© 2010, OpenThink Labs. All Rights Reserved
4. Querying
● Introduction to find
● Specifying Which Keys
to Return
● Limitations
● Query Criteria
● Query Conditionals
● OR Queries
● $not
● Rules for Conditionals
● Type-Specific Queries
● Null
● Regular Expressions
● Querying Arrays
● Querying on Embedded Documents
● $where Queries
● Cursors
● Limits, Skips, and Sorts
● Avoiding Large Skips
● Advanced Query Options
● Getting Consistent Results
● Cursor Internals
© 2010, OpenThink Labs. All Rights Reserved
5. Indexing
● Introduction to Indexing
● Scaling Indexes
● Indexing Keys in Embedded
Documents
● Indexing for Sorts
● Uniquely Identifying Indexes
● Unique Indexes
● Dropping Duplicates
● Compound Unique Indexes
● Using explain and hint
● Index Administration
● Changing Indexes
● Geospatial Indexing
● Compound Geospatial
Indexes
● The Earth Is Not a 2D
Plane
© 2010, OpenThink Labs. All Rights Reserved
6. Aggregation
● Count
● Distinct
● Group
● Using a Finalizer
● Using a Function as a Key
● MapReduce
● Example 1: Finding All Keys in a Collection
● Example 2: Categorizing Web Pages
● MongoDB and MapReduce
© 2010, OpenThink Labs. All Rights Reserved
7. Advanced Topics
● Database Commands
● How Commands Work
● Command Reference
● Capped Collections
● Properties and Use Cases
● Creating Capped Collections
● Sorting Au NaturelTailable Cursors
● GridFS: Storing Files
● Getting Started with GridFS:
mongofiles
● Working with GridFS from the
MongoDB Drivers
● Under the Hood
● Server-Side Scripting
● db.eval
● Stored JavaScript
● Security
● Database References
● What Is a DBRef?
● Example Schema
● Driver Support for DBRefs
● When Should DBRefs Be
Used?
© 2010, OpenThink Labs. All Rights Reserved
8. Administration
● Starting and Stopping
MongoDB
● Starting from the Command
Line
● File-Based Configuration
● Stopping MongoDB
● Monitoring
● Using the Admin Interface
● serverStatus
● Mongostat
● Third-Party Plug-Ins
● Security and Authentication
● Authentication Basics
● How Authentication Works
● Other Security Considerations
● Backup and Repair
● Data File Backup
● mongodump and mongorestore
● fsync and Lock
● Slave Backups
● Repair
© 2010, OpenThink Labs. All Rights Reserved
9. Replication
● Master-Slave
Replication
● Options
● Adding and Removing
Sources
● Replica Sets
● Initializing a Set
● Nodes in a Replica Set
● Failover and Primary
Election
● Performing Operations on a Slave
● Read Scaling
● Using Slaves for Data Processing
● How It Works
● The Oplog
● Syncing
● Replication State and the Local
Database
● Blocking for Replication
● Administration
● Diagnostics
● Changing the Oplog Size
● Replication with Authentication
© 2010, OpenThink Labs. All Rights Reserved
10. Sharding
● Introduction to Sharding
● Autosharding in MongoDB
● When to Shard
● The Key to Sharding: Shard
Keys
● Sharding an Existing Collection
● Incrementing Shard Keys
Versus Random Shard Keys
● How Shard Keys Affect
Operations
● Setting Up Sharding
● Starting the Servers
● Sharding Data
● Production Configuration
● A Robust Config
● Many mongos
● A Sturdy Shard
● Physical Servers
● Sharding Administration
● config Collections
● Sharding Commands
© 2010, OpenThink Labs. All Rights Reserved
11. Example Applications
● Chemical Search Engine: Java
● Installing the Java Driver
● Using the Java Driver
● Schema Design
● Writing This in Java
● Issues
● News Aggregator: PHP
● Installing the PHP Driver
● Using the PHP Driver
● Designing the News Aggregator
● Trees of Comments
● Voting
● Custom Submission Forms: Ruby
● Installing the Ruby Driver
● Using the Ruby Driver
● Custom Form Submission
● Ruby Object Mappers and Using
MongoDB with Rails
● Real-Time Analytics: Python
● Installing PyMongo
● Using PyMongo
● MongoDB for Real-Time Analytics
● Schema
● Handling a Request
● Using Analytics Data
● Other Considerations
© 2010, OpenThink Labs. All Rights Reserved
A. Installing MongoDB
© 2010, OpenThink Labs. All Rights Reserved
B. mongo: The Shell
© 2010, OpenThink Labs. All Rights Reserved
C. MongoDB Internals
© 2010, OpenThink Labs. All Rights Reserved
Buy this book, on Amazon!
© 2010, OpenThink Labs. All Rights Reserved
Q&A
Thanks! ^_^

MongoDB : The Definitive Guide

  • 1.
    © 2010, OpenThinkLabs. All Rights Reserved MongoDB The Definitive Guide Wildan Maulana wildan.m@openthinklabs.com
  • 2.
    © 2010, OpenThinkLabs. All Rights Reserved 1. Introduction ● A Rich Data Model ● Easy Scaling ● Tons of Features… ● …Without Sacrificing Speed ● Simple Administration ● But Wait, That’s Not All…
  • 3.
    © 2010, OpenThinkLabs. All Rights Reserved 2. Getting Started ● Documents ● Collections ● Schema-Free ● Naming ● Databases ● Getting and Starting MongoDB ● MongoDB Shell ● Running the Shell ● A MongoDB Client ● Basic Operations with the Shell ● Tips for Using the Shell ● Data Types ● Basic Data Types ● Numbers ● Dates ● Arrays ● Embedded Documents ● _id and ObjectIds
  • 4.
    © 2010, OpenThinkLabs. All Rights Reserved 3. Creating, Updating, and Deleting Documents ● Inserting and Saving Documents ● Batch Insert ● Inserts: Internals and Implications ● Removing Documents ● Remove Speed ● Updating Documents ● Document Replacement ● Using Modifiers ● Upserts ● Updating Multiple Documents ● Returning Updated Documents ● The Fastest Write This Side of Mississippi ● Safe Operation ● Catching “Normal” Errors ● Requests and Connections
  • 5.
    © 2010, OpenThinkLabs. All Rights Reserved 4. Querying ● Introduction to find ● Specifying Which Keys to Return ● Limitations ● Query Criteria ● Query Conditionals ● OR Queries ● $not ● Rules for Conditionals ● Type-Specific Queries ● Null ● Regular Expressions ● Querying Arrays ● Querying on Embedded Documents ● $where Queries ● Cursors ● Limits, Skips, and Sorts ● Avoiding Large Skips ● Advanced Query Options ● Getting Consistent Results ● Cursor Internals
  • 6.
    © 2010, OpenThinkLabs. All Rights Reserved 5. Indexing ● Introduction to Indexing ● Scaling Indexes ● Indexing Keys in Embedded Documents ● Indexing for Sorts ● Uniquely Identifying Indexes ● Unique Indexes ● Dropping Duplicates ● Compound Unique Indexes ● Using explain and hint ● Index Administration ● Changing Indexes ● Geospatial Indexing ● Compound Geospatial Indexes ● The Earth Is Not a 2D Plane
  • 7.
    © 2010, OpenThinkLabs. All Rights Reserved 6. Aggregation ● Count ● Distinct ● Group ● Using a Finalizer ● Using a Function as a Key ● MapReduce ● Example 1: Finding All Keys in a Collection ● Example 2: Categorizing Web Pages ● MongoDB and MapReduce
  • 8.
    © 2010, OpenThinkLabs. All Rights Reserved 7. Advanced Topics ● Database Commands ● How Commands Work ● Command Reference ● Capped Collections ● Properties and Use Cases ● Creating Capped Collections ● Sorting Au NaturelTailable Cursors ● GridFS: Storing Files ● Getting Started with GridFS: mongofiles ● Working with GridFS from the MongoDB Drivers ● Under the Hood ● Server-Side Scripting ● db.eval ● Stored JavaScript ● Security ● Database References ● What Is a DBRef? ● Example Schema ● Driver Support for DBRefs ● When Should DBRefs Be Used?
  • 9.
    © 2010, OpenThinkLabs. All Rights Reserved 8. Administration ● Starting and Stopping MongoDB ● Starting from the Command Line ● File-Based Configuration ● Stopping MongoDB ● Monitoring ● Using the Admin Interface ● serverStatus ● Mongostat ● Third-Party Plug-Ins ● Security and Authentication ● Authentication Basics ● How Authentication Works ● Other Security Considerations ● Backup and Repair ● Data File Backup ● mongodump and mongorestore ● fsync and Lock ● Slave Backups ● Repair
  • 10.
    © 2010, OpenThinkLabs. All Rights Reserved 9. Replication ● Master-Slave Replication ● Options ● Adding and Removing Sources ● Replica Sets ● Initializing a Set ● Nodes in a Replica Set ● Failover and Primary Election ● Performing Operations on a Slave ● Read Scaling ● Using Slaves for Data Processing ● How It Works ● The Oplog ● Syncing ● Replication State and the Local Database ● Blocking for Replication ● Administration ● Diagnostics ● Changing the Oplog Size ● Replication with Authentication
  • 11.
    © 2010, OpenThinkLabs. All Rights Reserved 10. Sharding ● Introduction to Sharding ● Autosharding in MongoDB ● When to Shard ● The Key to Sharding: Shard Keys ● Sharding an Existing Collection ● Incrementing Shard Keys Versus Random Shard Keys ● How Shard Keys Affect Operations ● Setting Up Sharding ● Starting the Servers ● Sharding Data ● Production Configuration ● A Robust Config ● Many mongos ● A Sturdy Shard ● Physical Servers ● Sharding Administration ● config Collections ● Sharding Commands
  • 12.
    © 2010, OpenThinkLabs. All Rights Reserved 11. Example Applications ● Chemical Search Engine: Java ● Installing the Java Driver ● Using the Java Driver ● Schema Design ● Writing This in Java ● Issues ● News Aggregator: PHP ● Installing the PHP Driver ● Using the PHP Driver ● Designing the News Aggregator ● Trees of Comments ● Voting ● Custom Submission Forms: Ruby ● Installing the Ruby Driver ● Using the Ruby Driver ● Custom Form Submission ● Ruby Object Mappers and Using MongoDB with Rails ● Real-Time Analytics: Python ● Installing PyMongo ● Using PyMongo ● MongoDB for Real-Time Analytics ● Schema ● Handling a Request ● Using Analytics Data ● Other Considerations
  • 13.
    © 2010, OpenThinkLabs. All Rights Reserved A. Installing MongoDB
  • 14.
    © 2010, OpenThinkLabs. All Rights Reserved B. mongo: The Shell
  • 15.
    © 2010, OpenThinkLabs. All Rights Reserved C. MongoDB Internals
  • 16.
    © 2010, OpenThinkLabs. All Rights Reserved Buy this book, on Amazon!
  • 17.
    © 2010, OpenThinkLabs. All Rights Reserved Q&A Thanks! ^_^