Mongodb is the first step towards making the database no SQL. Earlier all the database where based upon RDBMS.

All the data is stored in tables , tables consists of many rows and columns. So for managing complex application like
social networking websites, mobile applications , mongodb database is used.

The basic difference between traditional database and mongodb is. In Mongodb the data is stored in collections and a collections consists of multiple documents.
The document contains data in the form of json. Istead of rows and columns , the document stored the values in json

{“name”: “john”, “year” : “2012” }

So in RDBMS we have

database > tables > rows & columns

In mongodb we have

database > collection > document

Managing data in case of mongodb is simple as all the data is stored in json format.

2) In order to start using Mongodb , we need to install it on our system from the Mongodb website. it provides installer for windows , mac and all other platforms.

Just download it and install it on your system. For windows , the website provides msi file.

Once Mongodb is installed, it will setup all the path and other information on your system.

3) Now Mongodb is installed on your machine , it is now time to start writing the queries. You can do it by using the command prompt or the user interface provided by the Mongodb

The commonly used command are

1) Create database

Open the command prompt and write the command

c:\mongodb\ db.createCollection(“newdatabase”);

db.createCollection(“tablename”) -> This command is used to create a new collection in the database.

2) In order to check if the collection has been created or not

c:\mongodb\ showCollections

The showCollections command , will list all the collection created in the database.

3) Drop collection :


The above command is used to drop the collection from database.


4)Insert data into mongodb

First we create a json variable and then that json variable is used to store the data in database

var a={“name” : “shalabh ojha” , “year” :”2015″ };
This will save the variable a with json data in the database.
When we insert a new docuemnt in the collection, Mongodb automatically creates new unique id for each document.

5) Search operation in mongodb

db.newdatabase.find(“name” : “shalabh ojha”);

This will find any occurance of “shalabh ojha” in the document.


6) You can also remove data from the collection using remove command


7) Update command :

you can make single as well as multiple update command using Mongodb.

db.newdatabase.update(“name” : “newname”);

So the above mongodb tutorial gives you the basic overiew of installing mongodb and executing set of commands.

In this mongodb tutorial , we also learnt difference between RDBMS AND Mongodb.



395total visits,3visits today