Wednesday, 16 January 2013

MongoDB : What , Why and When ?

What is MongoDB ?
MongoDB is an open-source database system , developed by 10gen which is document-oriented unlike many other relational databases like mysql . It belongs to a family known as "NoSQL" . Instead of storing data in tables , like relational databases , MongoDB stores data in JSON-like documents , the format being commonly known as BSON . However it incorporates some traditional features like replication , indexing etc much like normal relational databases do . It incorporates a javascript shell , through which we can carry out the common querying tasks .

MongoDB Meme
Mongo FTW !!

Why should MongoDb be used and when should we use it ?
MongoDb , like other NoSQL Databases , is used , when the data under question does not follow a relational model . 

For example :-
"_id" : ObjectId("4b2b9f67a1f631733d917a7a"),
"name" : "Anurag",
"lastname" : Das,

"_id" : ObjectId("4b2b9f67a1f631733d917a7c"),
"Country" : "India",
"State" : "West Bengal",

Both of these documents (analogous to rows in SQL) are a part of the same collection (analogous to tables) , notice that the two field names are different !! Cool , isn't it ? That's the flexibility you get by using MongoDB , or other NoSQL Databases

The data can be structured , that is not a problem , but it's used when retreival of large amounts of data from the database , rather than the relationship between the data items , matter the most . In the posts to follow you'll get a clear understanding as to what is MongoDB and how you should use it .

1 comment: