w3resource logo

Mongodb Tutorial Introduction

Introduction to MongoDb

rating MongoDb Tutorial has average rating 6 out of 10. Total 65 users rated.


What is MongoDb

MongoDb is a Open Source database written in C++.

If the load increases, by adding more nodes (such as a computer), the performance can be retained.

It can be used to store data for very high performance applications (for example Foursquare is using it in production).

MongoDB Logo

MongoDb stores data as documents. So it is a document oriented database.

FirstName="Arun", Address="St. Xavier's Road", Spouse=[{Name:"Kiran"}], Children=[{Name:"Rihit", Age:8}].
FirstName="Sameer",Address="8 Gandhi Road".

Notice there are two different documents (separated by "."). Storing data in this fashion is called as document oriented database. MongoDb is a document oriented database.

Key Features

Since MongoDb offers a Document oriented storage, It is simple and easily programmable.

You can set an index on any attribute of a MongoDb record (as FirstName="Sameer",Address="8 Gandhi Road"), with respect to which, a record can be sort quickly and ordered.

You can set mirror across local as well as wide area networks, which makes it easily scalable.

If load increases (more storage space, more processing power), it can be distributed to other nodes across computer networks. This is called as sharding.

MongoDb supports rich query to fetch data from the database.

MongoDb supports replacing an entire document (database) or some specific fields with it's update() command.

MongoDb supports Map/Reduce framework for batch processing of data and aggregation operation. Here is brief of how Map/Reduce works :

Map : A master node takes an input. Splits it into smaller sections. Sends it to the associated nodes.

These nodes may perform the same operation in turn to send those smaller section of input to other nodes. It process the problem (taken as input) and sends it back to the Master Node.

Reduce : The master node aggregates those results to find the output.

GridFS specification of MongoDb supports storage of very large files.

MongoDb supports various programming languages like C, C# and .NET, C++, Erlang, Haskell, Java, Javascript, Perl, PHP, Python, Ruby, Scala (via Casbah).

It supports Server-side JavaScript execution. Which allows a developer to use a single programming language for both client and server side code.

MongoDb is easily installable.


Development of MongoDB began in October 2007 by 10gen. The first public release was in February 2009.

Obtain MongoDb

You can download MongoDb from http://www.mongodb.org/downloads. As of this writing, it supports following platforms:

OS X 32-bit

OS X 64-bit

Linux 32-bit

Linux 64-bit

Windows 32-bit

Windows 64-bit

Solaris i86pc

Solaris 64

You can download the source and install MongoDb from that too.


There are several tools available for managing MongoDB.


Network and System monitoring tool Munin has a plugin available for MongoDB.

Distributes high-performance system monitoring tool Gangila has a plugin available for MongoDB.

Open source web based graphic tool Cacti, used to graph CPU load, network bandwidth utilization, has a plugin available for MongoDB.


Fang of Mongo is a web-based user interface built with Django and jQuery.

Futon4Mongo is a clone of the CouchDB Futon web interface for MongoDB.

Mongo3 is a Ruby-based interface.

MongoHub is a native OS X application for managing MongoDB.

Opricot is a browser-based MongoDB shell written in PHP.

phpMoAdmin is a PHP based MongoDb management tool.

MongoVUE is a Windows based GUI to work with MongoDB.

RockMongo is a PHP based MongoDB administration GUI tool.

MongoDB in production

Here is a list of a few MongoDB production deployment :

Craiglist uses MongoDb to archive there billions of records.

FourSquare, a location based social networking site, uses MongoDb to shrade there data over a number of machines on Amazon EC2.

Shutterfly, an Internet-based social expression and personal publishing service, uses MongoDb for various persistent data storage requirements.

bit.ly, a web based url shortening service, uses MongoDb for storing their data.

spike.com, a MTV Network's associate, uses MongoDB.

Intuit, a large provider of software and services for small businesses and individuals, uses MongoDB to track user engagement and activity in real-time across its network of websites for small businesses.

sourceforge.net, a site to find, create and publish Open Source Software for free, uses MongoDB for back-end storage.

etsy.com, a site to buy and sell handmade items, uses MongoDB.

The New York Times, one of the leading online news portal, is using MongoDB in a form-building application for photo submissions.

CERN, the prestigious particle Physics research institute, uses MongoDB for Large Hadron Collider data.

What you will learn

w3resource's MongoDb tutorial is first of it's kind on internet. This is a comprehensive tutorial on MongoDb, covering hundreds of examples on how to use it with PHP.

After reading this tutorial, you will be able to install and develop Web base applications using MongoDB