Advantages of using NoSQL database like MongoDB

NoSQL database MongoDB

MongoDB is simply a database but not a relational database, it’s a NoSQL database.

By the term NoSQL, I don’t mean to say that it’s not SQL. The NoSQL here supplements not only SQL databases it can perform a lot more than that. So it is simply a database with a lot of things. Lots of pros and cons just like everything in the world.

I am not saying this is the world’s best database because everything in the world has its own pros and cons.

JSON Database

NoSQL database MongoDB stores data in a flexible json-like document. What makes everything easy with a JSON database is the mapping of the object.

When you store everything into table rows in columns accessing the data can be a little bit challenging and can be a costly process for your processor or may be a database unit. 

But in NoSQL, everything is stored in a mapping of key-value pairs. That’s why it is much easier, faster and everything is so easy and simple.

Simplicity

Because of the simplicity in the NoSQL database MongoDB, a lot of people believe that this simplicity can introduce so many problems. 

That is also correct that since there is so much flexibility given to you if your test set is not written properly you can introduce some data sets that you don’t want to and it’s not like it’s a con of the MongoDB it’s about how you’re structuring your database.

Distributed

It is a distributed database at its core so high availability horizontal scanning and Geographic distributions are built in and easy to use

The scalability is one kind of an issue with the SQL database. Because of distributed model scaling is super easy in MongoDB and one of the reasons why MongoDB is getting high in demand

Easy implementation and modification

Just to put an example if you want to build an application which is using geo-special data. In this application the user wants to see his geographic location and who are the other people near me in the location.

Doing this kind of thing with SQL databases is definitely one of the toughest things, it is surely doable but the toughest thing. It is very easy to implement in the NoSQL database MongoDB. 

Lets understand with another example:

you want to open up a simple eCommerce website you have a set field but later on you realise that the laptop section of this website should have one more section like a specification section or maybe a processor section.

This kind of change requires schema modification in SQL and hence come the solution as MongoDB, because no schema modification will be required, you can easily achieve by adding an additional field

Who is using MongoDB:

NokiaChicos
MedtronicAdobe
ebayGoogle
CISCOSAP
BarclaysRoyal Bank of Scotland
PaypalVerizon
Source: https://www.mongodb.com/who-uses-mongodb

Now coming onto one more point which is who is using mongoDB and to be honest the list is so big that I cannot even cover few of them

These are few that I have given in front of you are the reason of the screenshot here is just one guy on the very right inside at the bottom Royal bank of Scotland. 

I have heard this so many times that SQL is much more reliable than MangoDB which is not at all perfectly correct

surely both databases are reliable that’s why they are so much in the market but people say that if you want to design something like banks or any kind database is related to totally Bank then you should always choose SQL that can be a correct statement but see here Royal Bank of Scotland is using MongoDB  

That means if you write a test Suite properly you write your code properly you definitely can use it even in the banking systems as well that’s clear up another myth of MangoDB that it cannot be used in the bank sector.

It is totally you met with the proper usage of proper code. It can be used almost anywhere and since a website like eBay is using it hence have the proof that it can be used for commercial purpose everywhere here. 

Language support:

Now MongoDB supports my favourite programming language and your favourite programming languages that can be PHP, C Sharp, Ruby, Scala etc.

We can see in the following table MongoDB supports a couple of good famous programming languages. All the popular market languages are being supported and new supports are releasing in coming almost every single day they are working on it.

ActionscriptErlang
PerlC
GoPHP
C#Groovy
PowershellC++
HaskellProlog
ClojureJAVA
PythonColdfusion
JavascriptR
DLisp
RubyDart
LuaScala
DelphiMatLab
Smalltalk

Is MongoDB open source?

MongoDB is an open source NoSQL database.

There are two editions of MongoDB.

Open Source

This edition is freely available as a part of the open source community except for the other edition, you would like to buy the license.

Enterprise edition

Enterprise edition has some advanced features compared to the free edition. MongoDB Open Source is one of the leading NoSQL databases and widely accepted by many professionals.

MongoDB download for windows

A Step by step guide to download and install MongoDB on your Windows operating system.

MongoDB is a free and open-source cross-platform document-oriented database it is also classified as a NoSQL database program

so let’s see how we can install MongoDB on Windows operating system so 

  1. First of all open your favorite browser and search for MongoDB and the first link which will appear will be mongodb.com
  2. Click on try it free download center page is open you will be able to see different options here 
  3. The one we want to download and install is the community server so just click on the community server and then select windows
  4. Select platform windows and just click on this Downloads button which is going to start the download of this MongoDB MSI file 
  5. So once the download of this MSI file is complete. Click on this MSI file
  6. Installation wizard will get open
  7. Click Next and then you need to accept the license terms and conditions and then click Next 
  8. on this next window, you will see two options one is complete and other is custom
  9. Use the complete option so we are going to install the complete version of MongoDB with the extra features 
  10. on the next window, you will see this option which says install MongoDB as a service
  11. so leave this as default which says run service as the Network service user
  12. Create two directories one is the data directory and other is the log directory at the locations specified
  13. Leave everything as default and click Next
  14. Next window will ask you if you want to install a MongoDB compass
  15. MongoDB Compass is an official graphical user interface for MongoDB so leave this checkbox as checked
  16.  Click Next so now the installation of MongoDB will start
  17. After the installation of MongoDB is successfully finished you will see this window it says completed the MongoDB
  18. It will ask you to click the finish button so click the finish button
  19. Now once the MongoDB is installed on our Windows operating system 
  20. Go to the location where MongoDB is installed
  21. Just go to your C directory and then Program Files and you will be able to see this MongoDB folder here
  22. Click on server and then click on whatever version of MongoDB you have installed there will be a folder created with that version name
  23.  Click on this version name and then you will be able to see all these files and folders here
  24. Now click on the bin folder and here you will find all the MongoDB related executable files
  25. To start MongoDB you need to run this file which is Mongo D
  26. in order to open the MongoDB client you need to run this file which is Mongo
  27.  Just copy this part here so in order to run the Mongo D command start the command prompt
  28. so just right-click on windows icon and then choose command prompt which is going to start the command prompt 
  29. Go to CD to the folder where this Mongo D andMongo files are there so CD and paste
  30. The part you have copied for this bin folder and then press Enter 
  31. Inside this bin folder, all these files are located 
  32. Go inside this bin folder and here you just need to run this Mongo D command 
  33. Just run Mongo D and then press Enter
  34. Which is going to start the MongoDB server 
  35. But after the starting of MongoDB server, it’s going to give you this error which says that there is a special directory required which is undersea data and DB which is not found 
  36. so we need to create data directory and inside this data directory, create the DB directory in order to run this Mongo D command 
  37. Go to the C directory and here create a new directory with the name data
  38. Inside this data, directory create a new directory with the name DB 
  39. Just create the new directory with the name DB now this folder path is existing on Windows operating system 
  40. Once you run this Mongo D command it’s not going to give you any problem and you can see Mongo demon has been started
  41. Once this Mongo daemon is started I’m going to open the next terminal so right-click on this Windows icon and then click on command prompt
  42. and once again goto CD to the directory where Mongo and Mongo D executable files are there 
  43. Once again CD to the bin directory of MongoDB 
  44. And run the Mongo command so just give this command which is Mongo and then press ENTER 
  45. Which is going to open the Mongo shell
  46. In order to show all the databases which are already there you just give this command show DB’s
  47. Which is going to show you all the default databases which are already existing inside your MongoDB 
  48. Now in order to create a new database using MongoDB, you use this command use and the name of your database 
  49. Let’s say I want to create a database called my Lib
  50. Just give the name of your database after use and this is going to create this database 
  51. When you give the show DBS command it’s going to only show you the old databases and not the new one this is because you need to insert some data into your database in order to see it using the show DBS command
  52. In order to insert some data you just need to give this command 
  53. Switched to my Lib database using this use my lib command and now you just need to give this command DB dot the name of your collection 
  54. Let’s say my collection name is books and then dot insert and give the parentheses and inside the parentheses you give the curly brackets and you give your values as Jason’s so inside the curly brackets you just need to provide that key name 
  55. Let’s say the key name is name and then colon so for example the value is MongoDB book and press Enter
  56. A collection will be created and insert this document into your collection and once again when you give this show DBS command 
  57. you will see our database is now listed here now in order to list out all the collections inside your database you just need to give this command which is
    1. show collections and then the semicolon and then press ENTER 
    2. which is going to show all the collections which are present inside your database 
  58. Now in order to see all the values which are present inside your collection you just need to give once again DB command and then the name of your collection 
  59. So DB dot books and then give the find command in order to list all the equipments inside the collection
  60. When you give this command, you will see all the documents which are present inside your collection so this is how you can use this Mongo client
  61. Whenever you need to use the Mongo client you always need to start the Mongo daemon on the other shell so let
  62. In order to recognize your Mongo D command or Mongo command from anywhere, you need to set the environment variable for the MongoDB

Leave a comment

Previous

AWS Redshift Tutorial-Getting started with Amazon Redshift

Difference Between SQL and NoSQL Databases-SQL vs NoSQL

Next