Tuesday 15 March 2016

Development in MongoDB with NoSQL Manager!

Hello Guys,

 I would like to share some information about development in MongoDB with NoSQL Manager Studio. So the very first question will be, what is MongoDB?
MongoDB is basically an open source database which falls under NoSQL category.
With NoSQL I mean, it does not follow the traditional way of storing data in tables and rows. Instead, it stores data in the form of documents. These documents are in JSON format. 
MongoDB is fast and scalable. A database in MongoDB is a set of collections, which holds set of documents, one single document is a set of fields which is of key value pair. For e.g. Employee collection will have following information; 
{“EmployeId": 101, “EmployeName”:"James", "Email”:”none@none.com”,”City”: “New York”} 


NoSQL Manager
It is a tool for MongoDB Administration, Development and Management.  It gives you document viewer and editor with Tree, Table and JSON view modes. It allows import tables from MySQL and SQL Server databases.

Before moving into development, a very important step is to start database engine. 
To do so, 
1) Open command prompt and make this path “C:\Program Files\MongoDB\Server\3.2\bin” your current working directory. 
2) Type “MONGOD” and hit enter. This command will start mongo server process. As shown in below screen.
Now you are ready to develop and using MongoDB!!!

Development in MongoDB composed of below major steps:
1) Create a Database:-For creating new database in MongoDB, click on databases and select create new database. Enter the database name as shown below.

2) Query the Database: - Open shell prompt in NoSQL Manager and execute below commands for creating new collection and Insert some data into the Employees MongoDB database.
db.createCollection ("Employee", {size: 2147483647})
db.Employee.insert ({EmployeId: 1, EmployeName:"Rajesh", Email:"none@none.com", City:"Mumbai"})

Now, let’s execute a select query on Employee collection we just created, db.Employee.find ({EmployeName: "Rajesh"}). 
It will show you the actual document view in result of NoSQL Manager Studio.

 What’s more for SQL users??Import MS SQL Server Database into MongoDB:- 
Step 1:-Choose “Import data from External data sources” on Employee Database. Select your data sources (MS SQL Server Database) and database as mentioned in below screen.

Step 2:-After selection of database the next screen shows available tables in SQL Server SampleDB. I selected country table, which I want to import into my Employees MongoDB database as shown in below screen

Step 3:-Click next on same window and Execute selection. It will show number of document imported into MongoDB.
You can see new country collection is added into the collection of Employees Database.
Now let’s do select query on Country Collection for US country which shows below result.
One more interesting feature is that you can render same data in different views e.g. Tree view, Table view, Text view (JSON format). You can find those options in section highlighted in the below image.

That’s all friends!!
 I hope this will help you getting familiar with MongoDB.


5 comments: