Friday, October 3, 2014

Getting started with MongoDB

MongoDb is a cross platform document oriented database system.It is classified as NoSql database. It implements the traditional table based database in JSON like structure with dynamic schema named as BSON. That makes the integration of data in certain type of applications easier and faster.
MongoDb is most popular NoSql Database that is opted by huge and well know organisations as back-end for their applications.

Key Features 
  • High performance
  • High availability
  • Easy scalability
  • Open-Source
  • Huge support community


Train your mind to hear new terms in Database Context

Realtional DatabaseMongoDB
Table JoinEmbedded Documents
Primary KeyObject Id or Primary Key (Default key _id provided by mongodb itself) 


Database is a physical container for collections. Each database gets its own set of files on the file system. The database files are typically located at "C:\data\db" or where you configure the data folder during installation.


It is the equivalent of an RDBMS table. Collection is a group of MongoDB documents that exists within a single database. Collections do not enforce a schema. Documents within a collection can have different fields. But best practices and recommendations says, all documents in a collection are of similar or related purpose that is their schema's as approximately same.


A document is a JSON document with set of key-value pairs. Documents have dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.


Each key in the Document is referred as Field. It is equivalent to the column of the RDBMS.

Embedded Documents

MongoDB provides the flexibility of storing documents inside another document. The design schema totally depends upon the Database Architect but in general practice its a good approach to store a full fledged document that represents a complete entity on its own. The most common use case is to store comments inside a post document (opposite from traditional normalization point of view). but think of it remove the necessity of having a JOIN while rendering the complete blog post and a comment does not make any sense without its post. Therfore Embedded Documents or Sub-Documents are considered as the Table JOINs of RDBMS.

_id / Object Id

It is the unique primary key that pushed automatically in the document for querying and internal management of the documents by mongo. However Mongo also has provision to set the _id manually instead of having a long number.

Sample of document stored in MongoDb.

Advantages of MongoDB over RDBMS

  • Schema less : MongoDB is document database in which one collection holds different different documents. Number of fields, content and size of the document can be differ from one document to another.
  • Structure of a single object is clear
  • Support for embedded documents so No complex joins
  • Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL
  • Ease of tuning and scaling
  • Ease of scale-out: MongoDB is easy to scale
  • Conversion / mapping of application objects to database objects not needed
  • Uses internal memory for storing the (windowed) working set, enabling faster access of data


This mongodb is a good platform, I have used it when i took recored for my business of logo design services.

Post a Comment