In this chapter, we will focus on learning how to perform aggregation queries in MongoDB. In Chapter 2, Building your First MongoDB Powered Web App, we learned how to query a collection using the
find()
method. Aggregation queries are different from the queries we have done so far. These queries perform certain computations/calculations on the documents and the result of the computation is sent back to the user. For instance, grouping the documents on the value of a certain field and counting their values is a kind of aggregation operation. If you have experience with SQL, aggregation queries are the ones that useCOUNT/SUM/AVG/GROUP BY
statements. MongoDB uses MapReduce, a functional programming paradigm to perform aggregation and batch processing of data. In this chapter, we are going to familiarize ourselves with the concepts of MapReduce. We will learn how to perform MapReduce queries both in the mongo shell and in PHP. We will also learn to use utility...
PHP and MongoDB Web Development Beginner's Guide
PHP and MongoDB Web Development Beginner's Guide
Overview of this book
With the rise of Web 2.0, the need for a highly scalable database, capable of storing diverse user-generated content is increasing. MongoDB, an open-source, non-relational database has stepped up to meet this demand and is being used in some of the most popular websites in the world. MongoDB is one of the NoSQL databases which is gaining popularity for developing PHP Web 2.0 applications.PHP and MongoDB Web Development Beginner’s Guide is a fast-paced, hands-on guide to get started with web application development using PHP and MongoDB. The book follows a “Code first, explain later” approach, using practical examples in PHP to demonstrate unique features of MongoDB. It does not overwhelm you with information (or starve you of it), but gives you enough to get a solid practical grasp on the concepts.The book starts by introducing the underlying concepts of MongoDB. Each chapter contains practical examples in PHP that teache specific features of the database.The book teaches you to build a blogging application, handle user sessions and authentication, and perform aggregation with MapReduce. You will learn unique MongoDB features and solve interesting problems like real-time analytics, location-aware web apps etc. You will be guided to use MongoDB alongside MySQL to build a diverse data back-end.
With its concise coverage of concepts and numerous practical examples, PHP and MongoDB Web Development Beginner’s Guide is the right choice for the PHP developer to get started with learning MongoDB.
Table of Contents (17 chapters)
PHP and MongoDB Web Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Getting Started with MongoDB
Building your First MongoDB Powered Web App
Building a Session Manager
Aggregation Queries
Web Analytics using MongoDB
Using MongoDB with Relational Databases
Handling Large Files with GridFS
Building Location-aware Web Applications with MongoDB and PHP
Improving Security and Performance
Easy MongoDB Administration with RockMongo and phpMoAdmin
Pop Quiz Answers
Customer Reviews