MongoDB is an open source, JSON-based, document database and leading NoSql database written in C++ to deploy highly performance oriented and scalable database. It uses custom binary (BSON) protocol.
MongoDB has a simple but powerful javascript shell, which helps in administration of MongoDB instances and data manipulation. Its current stable version is 2.6.7 released in January, 2015 with aggregation enhancements, security improvements, query-engine improvements etc.
For installation steps, refer this link – http://docs.mongodb.org/manual/installation/
“Show me your code and conceal your data structures, and I shall continue to be mystified.
Show me your data structures, and I won’t usually need your code; it’ll be obvious.”
– Eric Raymond, the Cathedral and the Bazaar
True are these words that say data structure is of paramount importance. with MongoDB, we can model the data structure more easily and expressively. Let’s list some main features of MongoDB –
Document
A document is the key element in MongoDB. A document can be considered as a row in a table in traditional RDBMS. It is represented in key/value pairs i.e. an ordered set of keys with associative values. In JavaScript, for example, documents are represented as objects:
{“blog” : “mongodb!”}
Here, this simple document has single key “blog”with value “mongodb!”
Collection
A collection can be thought of as a table with a dynamic schema. A single instance of MongoDB can host multiple independent databases, each of which can have its own collections. Every document has a special key, “_id”, which is unique within a collection.
Data Manipulation
To insert data into MongoDB collection, you need to use insert() method –
>db.collection.insert(document)
>db.mycol.insert({
_id: ObjectId(8hju8ad8jb25),
title: ‘MongoDB Blog,
description: ‘Leading NoSql Database’,
version : 2.6,
format : json
})
To fetch data from MongoDB collection, use find() method –
>db.collection.find()
To update data, use update() method –
>db.collection.update(criteria, new_data)
>db.mycol.update({‘title’:’MongoDB Blog’},{$set:{‘title’:’Mongo Lab’}},{multi:true})
To delete data, use remove() method as follows –
>db.collection.remove(criteria)
For more data manipulation commands, refer to this link – http://docs.mongodb.org/manual/reference/command/
MongoDB has been adopted by numerous major websites and services, including Craigslist, eBay, Foursquare, SourceForge, Viacom, and the New York Times, among others as their backend.
If there are concurrent dynamic queries in your web application on enormous amount of data and you preferably define indexes over map/reduce functions, MongoDB is a good database to go for.