What is MongoDB?

MongoDB is an open source NoSQL database developed by 10Gen and is written in C++. It is different from MySQL as it is document based and not table-based. MongoDB is fast, its development time is quick as it is schemaless and has very little data mapping. Another reason for its fast working is because MongoDB is a document-oriented database that means it stores the entire document rather than storing data as rows in tables.

What is MongoDB?


MongoDB is an open source NoSQL database developed by 10Gen and is written in C++. It is different from MySQL as it is document based and not table-based. MongoDB is fast, its development time is quick as it is schemaless and has very little data mapping.

Another reason for its fast working is because MongoDB is a document-oriented database that means it stores the entire document rather than storing data as rows in tables. It is easy to crawl and pick up anything even horizontally, which was not possible in MySQL. Indexing is easy too as any field in a MongoDB document can be indexed.

MongoDB stores data in JSON documents

There are many advantages of using MongoDB by PHP developers:

  • For the very start MongoDB is a stand-alone server.
  • MongoDB has no schema language.
  • PHP developers does not require any other query language
  • MongoDB driver is available as a PECL extension to PHP

MongoDB also provides tools for querying, creating, updating, and deleting. It scales horizontally using Auto-Sharding and stores large media with GridFS.

Gaming companies, e-commerce companies, content management companies and various other companies can benefit form using MongoDB. Some companies like MTV Networks, Craigslist, Foursquare and UIDAI (Aadhaar) have already started using it and have shown benefit.

Example of MongoDB:

<?php
array(
'title' => 'RoseIndia',
'authors' => array('Bipul', 'Gopal', 'Amit'),
'body' => 'Rose India',
'tags' => array('tag4', 'tag5', 'tag6')
);
?>

How to set up MongoDB for Windows?

Download the MongoDB binaries from its official mongodb.org/downloads. It will be a zipped file. Unzip the downloaded binaries to a folder.

Then create a folder where MongoDB will store its data.

Run this command in your shell:

C:\> mkdir \data
C:\> mkdir \data\db

Finally, Run MongoDB. Go to MongoDB folder and run the mongod.exe:

C:\> cd \my_mongo_dir\bin
C:\my_mongo_dir\bin>mongod

To open the shell admin console, use this command:

C:\my_mongo_dir\bin>mongo