O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

MongoDB 4 Quick Start Guide

Book Description

A fast paced guide that will help you to create, read, update and delete data using MongoDB

Key Features

  • Create secure databases with MongoDB
  • Manipulate and maintain your database
  • Model and use data in a No SQL environment with MongoDB

Book Description

MongoDB has grown to become the de facto NoSQL database with millions of users, from small start-ups to Fortune 500 companies. It can solve problems that are considered difficult, if not impossible, for aging RDBMS technologies. Written for version 4 of MongoDB, this book is the easiest way to get started with MongoDB.

You will start by getting a MongoDB installation up and running in a safe and secure manner. You will learn how to perform mission-critical create, read, update, and delete operations, and set up database security. You will also learn about advanced features of MongoDB such as the aggregation pipeline, replication, and sharding.

You will learn how to build a simple web application that uses MongoDB to respond to AJAX queries, and see how to make use of the MongoDB programming language driver for PHP.

The examples incorporate new features available in MongoDB version 4 where appropriate.

What you will learn

  • Get a standard MongoDB database up and running quickly
  • Perform simple CRUD operations on the database using the MongoDB command shell
  • Set up a simple aggregation pipeline to return subsets of data grouped, sorted, and filtered
  • Safeguard your data via replication and handle massive amounts of data via sharding
  • Publish data from a web form to the database using a program language driver
  • Explore the basic CRUD operations performed using the PHP MongoDB driver

Who this book is for

Web developers, IT professionals and Database Administrators (DBAs) who want to learn how to create and manage MongoDB databases.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. MongoDB 4 Quick Start Guide
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Introducing MongoDB
    1. Overview of MongoDB
      1. Handling big data
      2. Modeling objects without SQL
    2. Installing MongoDB
      1. Installing MongoDB on Windows
        1. Download and install
        2. MongoDB Compass
        3. MongoDB Windows file locations
    3. Installing MongoDB on Linux
      1. Installing on Debian or Ubuntu Linux
        1. Package installation
        2. Configure and run MongoDB on Ubuntu/Debian
      2. Installing on Red Hat, Fedora, or CentOS Linux
        1. Package installation
        2. Configure and run MongoDB on RHEL/Fedora/CentOS
      3. Installing from source
    4. Summary
  8. Understanding MongoDB Data Structures
    1. What is NoSQL?
    2. Documents, collections, and database
    3. Data-modeling considerations
      1. References
      2. Embedded documents
      3. Document design
    4. Creating a MongoDB database and collection
    5. Summary
  9. Using the MongoDB Shell
    1. Overview
      1. Why use the mongo shell?
      2. Options when invoking the shell
      3. .mongorc.js File
      4. Informational commands
    2. Performing simple queries
      1. Defining a query filter
      2. Defining a projection
      3. Modifying the cursor
    3. Database and collection operations
      1. Working with databases
      2. Working with collections
    4. Creating, updating, or deleting documents
      1. Creating one or more documents
      2. Updating one or more documents
      3. Deleting one or more documents
    5. Creating and running shell scripts
      1. Running a direct command
      2. Running a shell script
    6. Summary
  10. Developing with Program Language Drivers
    1. Overview of the MongoDB PHP driver
      1. MongoDB PHP architecture
      2. MongoDB PHP extension classes
        1. MongoDB\Driver classes
        2. MongoDB\BSON classes
        3. MongoDB\Driver\ {Exception, Monitoring} classes
    2. Installing the MongoDB PHP extension
      1. ext/mongodb installation using PECL
      2. ext/mongodb installation on Windows
      3. Installing the PHP library for MongoDB (PHPLIB)
    3. Performing CRUD operations using PHPLIB
      1. Core PHPLIB class instances needed for CRUD operations
      2. Creating documents
      3. Reading documents
      4. Searching by ObjectId
      5. Updating documents
      6. Deleting documents
    4. Other libraries and framework integration
    5. Summary
  11. Building Complex Queries Using Aggregation
    1. An overview of aggregation
      1. What is aggregation?
      2. Why use aggregation?
    2. Using single-purpose aggregation
    3. Using the aggregation pipeline
      1. Aggregation pipeline stages
        1. $bucket
        2. $group
        3. $lookup
        4. $match
      2. Aggregation pipeline expression operators
      3. Aggregation pipeline accumulators
        1. $group stage accumulators
        2. $project and $addFields stage accumulators
      4. Aggregation pipeline expression operator examples
    4. Using map-reduce
    5. Using the MongoDB Compass aggregation pipeline builder
    6. Summary
  12. Maintaining MongoDB Performance
    1. Indexes
      1. Single field indexes
      2. Compound indexes
      3. Multi-key indexes
    2. Simple backup and restore
      1. mongodump
      2. mongorestore
    3. Replication
      1. Understanding MongoDB replication
      2. Deploying a replica set
        1. Resetting the IP address
        2. Configuring the replica set member
        3. Initializing the replica set
      3. Adding and removing members
        1. Removing a member from a replica set
        2. Adding a member to a replica set
    4. Sharding
      1. Understanding sharding
      2. Choosing a shard key
      3. Sharding strategies
        1. Ranged sharding
        2. Hashed sharding
      4. Deploying a sharded cluster
    5. Summary
  13. Securing MongoDB
    1. MongoDB security overview
    2. Transport Layer Security
      1. Changes in MongoDB v4.0
      2. x.509 certificates
      3. Configuring mongod to use TLS
    3. Authentication
      1. SCRAM
        1. Mongo shell authentication using SCRAM
        2. Internal communication using SCRAM
      2. x.509 authentication
        1. Mongo shell authentication using x.509
        2. Internal authentication using x.509
      3. Kerberos
      4. LDAP
    4. Access control
      1. Initializing security
      2. Database privilege actions
        1. CRUD privilege actions
        2. Database management privilege actions
        3. Infrastructure privilege actions
      3. Role-based access control
        1. Built-in roles
        2. Custom roles
      4. Database user administration
    5. Summary
  14. Getting from a Web Form to MongoDB
    1. Building the application
      1. Defining the initial view
        1. Defining the Add Purchase view
        2. Defining the JSON response script
      2. Defining the Connection class
      3. Defining the service classes
        1. Application\Base
        2. Application\Main
        3. Application\Lookup
        4. Application\Add
    2. Configuring transaction support
    3. Adding security
    4. Summary
  15. Using Docker
    1. Using MongoDB with Docker
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think