The Definitive Guide to MongoDB: A complete guide to dealing with Big Data using MongoDB, Second Edition

Book description

The Definitive Guide to MongoDB, Second Edition, is updated for the latest version and includes all of the latest MongoDB features, including the aggregation framework introduced in version 2.2 and hashed indexes in version 2.4. MongoDB is the most popular of the "Big Data" NoSQL database technologies, and it's still growing. David Hows from 10gen, along with experienced MongoDB authors Peter Membrey and Eelco Plugge, provide their expertise and experience in teaching you everything you need to know to become a MongoDB pro.

The Definitive Guide to MongoDB, Second Edition, starts with the basics, including how to install on Windows, Linux, and OS X, and how MongoDB handles your data. Then you'll learn how to develop with MongoDB with both PHP and Python, including an example application using a PHP driver to create a blog application. Finally, you'll dig into more advanced but extremely important MongoDB features, including optimization, replication, and sharding -- load-balancing that makes MongoDB ideal for dealing with Big Data.

If you're dealing with data, MongoDB should be on your must-learn list. The Definitive Guide to MongoDB, Second Edition, is just the book you need.

What you'll learn

  • Set up MongoDB on all major server platforms, including Windows, Linux, OS X, and cloud platforms like Rackspace, Azure, and Amazon EC2

  • Work with GridFS and the new aggregation framework

  • Work with your data using non-SQL commands

  • Write applications using either PHP or Python

  • Optimize MongoDB

  • Master MongoDB administration, including replication, replication tagging, and tag-aware sharding

  • Who this book is for

    Database admins and developers who need to get up to speed on MongoDB and its Big Data, NoSQL approach to dealing with data management.

    Table of contents

    1. Title Page
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. About the Authors
    6. About the Technical Reviewers
    7. Acknowledgments
    8. Introduction
    9. PART 1: MongoDB Basics
      1. CHAPTER 1: Introduction to MongoDB
        1. Reviewing the MongoDB Philosophy
          1. Using the Right Tool for the Right Job
          2. Lacking Innate Support for Transactions
          3. JSON and MongoDB
          4. Adopting a Nonrelational Approach
          5. Opting for Performance vs. Features
          6. Running the Database Anywhere
        2. Fitting Everything Together
          1. Generating or Creating a Key
          2. Using Keys and Values
          3. Implementing Collections
          4. Understanding Databases
        3. Reviewing the Feature List
          1. Using Document-Oriented Storage (BSON)
          2. Supporting Dynamic Queries
          3. Indexing Your Documents
          4. Leveraging Geospatial Indexes
          5. Profiling Queries
          6. Updating Information In-Place
          7. Storing Binary Data
          8. Replicating Data
          9. Implementing Sharding
          10. Using Map and Reduce Functions
          11. The All-New Aggregation Framework
        4. Getting Help
          1. Visiting the Website
          2. Chatting with the MongoDB Developers
          3. Cutting and Pasting MongoDB Code
          4. Finding Solutions on Google Groups
          5. Leveraging the JIRA Tracking System
        5. Summary
      2. CHAPTER 2: Installing MongoDB
        1. Choosing Your Version
          1. Understanding the Version Numbers
        2. Installing MongoDB on Your System
          1. Installing MongoDB under Linux
          2. Installing MongoDB under Windows
        3. Running MongoDB
          1. Prerequisites
          2. Surveying the Installation Layout
          3. Using the MongoDB Shell
        4. Installing Additional Drivers
          1. Installing the PHP Driver
          2. Confirming That Your PHP Installation Works
          3. Installing the Python Driver
          4. Confirming That Your PyMongo Installation Works
        5. Summary
      3. CHAPTER 3: The Data Model
        1. Designing the Database
          1. Drilling Down on Collections
          2. Using Documents
          3. Creating the _id Field
        2. Building Indexes
          1. Impacting Performance with Indexes
        3. Implementing Geospatial Indexing
          1. Querying Geospatial Information
        4. Using MongoDB in the Real World
        5. Summary
      4. CHAPTER 4: Working with Data
        1. Navigating Your Databases
          1. Viewing Available Databases and Collections
        2. Inserting Data into Collections
        3. Querying for Data
          1. Using the Dot Notation
          2. Using the Sort, Limit, and Skip Functions
          3. Working with Capped Collections, Natural Order, and $natural
          4. Retrieving a Single Document
          5. Using the Aggregation Commands
          6. Working with Conditional Operators
          7. Leveraging Regular Expressions
        4. Updating Data
          1. Updating with update( )
          2. Implementing an Upsert with the save( ) Command
          3. Updating Information Automatically
          4. Specifying the Position of a Matched Array
          5. Atomic Operations
          6. Modifying and Returning a Document Atomically
        5. Renaming a Collection
        6. Removing Data
        7. Referencing a Database
          1. Referencing Data Manually
          2. Referencing Data with DBRef
        8. Implementing Index-Related Functions
          1. Surveying Index-Related Commands
          2. Forcing a Specified Index to Query Data
          3. Constraining Query Matches
        9. Summary
      5. CHAPTER 5: GridFS
        1. Filling in Some Background
        2. Working with GridFS
        3. Getting Started with the Command-Line Tools
          1. Using the _id Key
          2. Working with Filenames
          3. Determining a File’s Length
          4. Working with Chunk Sizes
          5. Tracking the Upload Date
          6. Hashing Your Files
        4. Looking Under MongoDB’s Hood
          1. Using the search Command
          2. Deleting
          3. Retrieving Files from MongoDB
          4. Summing Up mongofiles
        5. Exploiting the Power of Python
          1. Connecting to the Database
          2. Accessing the Words
        6. Putting Files into MongoDB
        7. Retrieving Files from GridFS
        8. Deleting Files
        9. Summary
    10. PART 2: Developing with MongoDB
      1. CHAPTER 6: PHP and MongoDB
        1. Comparing Documents in MongoDB and PHP
        2. MongoDB Classes
        3. Connecting and Disconnecting
        4. Inserting Data
        5. Listing Your Data
          1. Returning a Single Document
          2. Listing All Documents
          3. Using Query Operators
          4. Querying for Specific Information
          5. Sorting, Limiting, and Skipping Items
          6. Counting the Number of Matching Results
          7. Grouping Data with the Aggregation Framework
          8. Specifying the Index with Hint
          9. Refining Queries with Conditional Operators
          10. Regular Expressions
        6. Modifying Data with PHP
          1. Updating via update( )
          2. Saving Time with Update Operators
          3. Upserting Data with save( )
          4. Modifying a Document Atomically
        7. Deleting Data
        8. DBRef
          1. Retrieving the Information
        9. GridFS and the PHP Driver
          1. Storing Files
          2. Adding More Metadata to Stored Files
          3. Retrieving Files
          4. Deleting Data
        10. Summary
      2. CHAPTER 7: Python and MongoDB
        1. Working with Documents in Python
        2. Using PyMongo Modules
        3. Connecting and Disconnecting
        4. Inserting Data
        5. Finding Your Data
          1. Finding a Single Document
          2. Finding Multiple Documents
          3. Using Dot Notation
          4. Returning Fields
          5. Simplifying Queries with sort( ), limit( ), and skip( )
          6. Aggregating Queries
          7. Specifying an Index with hint( )
          8. Refining Queries with Conditional Operators
          9. Conducting Searches with Regular Expressions
        6. Modifying the Data
          1. Updating Your Data
          2. Modifier Operators
          3. Saving Documents Quickly with save( )
          4. Modifying a Document Atomically
          5. Putting the Parameters to Work
        7. Deleting Data
        8. Creating a Link Between Two Documents
          1. Retrieving the Information
        9. Summary
      3. CHAPTER 8: Advanced Queries
        1. Text Search
          1. Text Search Costs and Limitations
          2. Enabling Text Search
          3. Using Text Search
          4. Text Indexes in Other Languages
          5. Compound Indexing with Text Indexes
        2. The Aggregation Framework
          1. $group
          2. $limit
          3. $match
          4. $sort
          5. $unwind
          6. $skip
        3. MapReduce
          1. How MapReduce Works
          2. Setting Up Testing Documents
          3. Working with Map functions
          4. Advanced MapReduce
          5. Debugging MapReduce
        4. Summary
    11. PART 3: Advanced MongoDB with Big Data
      1. CHAPTER 9: Database Administration
        1. Using Administrative Tools
          1. mongo, the MongoDB Console
          2. Using Third-Party Administration Tools
        2. Backing Up the MongoDB Server
          1. Creating a Backup 101
          2. Backing Up a Single Database
          3. Backing Up a Single Collection
        3. Digging Deeper into Backups
        4. Restoring Individual Databases or Collections
          1. Restoring a Single Database
          2. Restoring a Single Collection
        5. Automating Backups
          1. Using a Local Datastore
          2. Using a Remote (Cloud-Based) Datastore
        6. Backing Up Large Databases
          1. Using a Hidden Secondary Server for Backups
          2. Creating Snapshots with a Journaling Filesystem
          3. Disk Layout to Use with Volume Managers
        7. Importing Data into MongoDB
        8. Exporting Data from MongoDB
        9. Securing Your Data by Restricting Access to a MongoDB Server
        10. Protecting Your Server with Authentication
          1. Adding an Admin User
          2. Enabling Authentication
          3. Authenticating in the mongo Console
          4. MongoDB User Roles
          5. Delegated Credentials
          6. Changing a User’s Credentials
          7. Adding a Read-Only User
          8. Deleting a User
          9. Using Authenticated Connections in a PHP Application
        11. Managing Servers
          1. Starting a Server
          2. Reconfiguring a Server
          3. Getting the Server’s Version
          4. Getting the Server’s Status
          5. Shutting Down a Server
        12. Using MongoDB Logfiles
        13. Validating and Repairing Your Data
          1. Repairing a Server
          2. Validating a Single Collection
          3. Repairing Collection Validation Faults
          4. Repairing a Collection’s Datafiles
          5. Compacting a Collection’s Datafiles
        14. Upgrading MongoDB
        15. Rolling Upgrade of MongoDB
        16. Monitoring MongoDB
        17. Using the MongoDB Management Service (MMS)
        18. Summary
      2. CHAPTER 10: Optimization
        1. Optimizing Your Server Hardware for Performance
          1. Understanding How MongoDB Uses Memory
          2. Understanding Working Set Size
          3. Choosing the Right Database Server Hardware
        2. Evaluating Query Performance
          1. The MongoDB Profiler
          2. Analyzing a Specific Query with explain( )
          3. Using the Profiler and explain( ) to Optimize a Query
        3. Managing Indexes
          1. Listing Indexes
          2. Creating a Simple Index
          3. Creating a Compound Index
        4. Specifying Index Options
          1. Creating an Index in the Background with {background:true}
          2. Creating an Index with a Unique Key {unique:true}
          3. Dropping Duplicates Automatically with {dropdups:true}
          4. Creating Sparse Indexes with {sparse:true}
          5. TTL Indexes
          6. Text Search Indexes
          7. Dropping an Index
          8. Reindexing a Collection
        5. How MongoDB Selects Which Indexes It Will Use
        6. Using hint( ) to Force Using a Specific Index
        7. Optimizing the Storage of Small Objects
        8. Summary
      3. CHAPTER 11: Replication
        1. Spelling Out MongoDB’s Replication Goals
          1. Improving Scalability
          2. Improving Durability/Reliability
          3. Providing Isolation
        2. Replication Fundamentals
          1. What Is a Primary?
          2. What Is a Secondary?
          3. What Is an Arbiter?
        3. Drilling Down on the Oplog
        4. Implementing a Replica Set
          1. Creating a Replica Set
          2. Getting a Replica Set Member Up and Running
          3. Adding a Server to a Replica Set
          4. Adding an Arbiter
          5. Replica Set Chaining
          6. Managing Replica Sets
          7. Configuring the Options for Replica Set Members
          8. Connecting to a Replica Set from Your Application
        5. Summary
      4. CHAPTER 12: Sharding
        1. Exploring the Need for Sharding
        2. Partitioning Horizontal and Vertical Data
          1. Partitioning Data Vertically
          2. Partitioning Data Horizontally
        3. Analyzing a Simple Sharding Scenario
        4. Implementing Sharding with MongoDB
          1. Setting Up a Sharding Configuration
          2. Determining How You’re Connected
          3. Listing the Status of a Sharded Cluster
          4. Using Replica Sets to Implement Shards
        5. The Balancer
        6. Hashed Shard Keys
        7. Tag Sharding
        8. Summary
    12. Index

    Product information

    • Title: The Definitive Guide to MongoDB: A complete guide to dealing with Big Data using MongoDB, Second Edition
    • Author(s):
    • Release date: November 2013
    • Publisher(s): Apress
    • ISBN: 9781430258216