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:
Nokia | Chicos |
Medtronic | Adobe |
ebay | |
CISCO | SAP |
Barclays | Royal Bank of Scotland |
Paypal | Verizon |
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.
Actionscript | Erlang |
Perl | C |
Go | PHP |
C# | Groovy |
Powershell | C++ |
Haskell | Prolog |
Clojure | JAVA |
Python | Coldfusion |
Javascript | R |
D | Lisp |
Ruby | Dart |
Lua | Scala |
Delphi | MatLab |
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
- First of all open your favorite browser and search for MongoDB and the first link which will appear will be mongodb.com
- Click on try it free download center page is open you will be able to see different options here
- The one we want to download and install is the community server so just click on the community server and then select windows
- Select platform windows and just click on this Downloads button which is going to start the download of this MongoDB MSI file
- So once the download of this MSI file is complete. Click on this MSI file
- Installation wizard will get open
- Click Next and then you need to accept the license terms and conditions and then click Next
- on this next window, you will see two options one is complete and other is custom
- Use the complete option so we are going to install the complete version of MongoDB with the extra features
- on the next window, you will see this option which says install MongoDB as a service
- so leave this as default which says run service as the Network service user
- Create two directories one is the data directory and other is the log directory at the locations specified
- Leave everything as default and click Next
- Next window will ask you if you want to install a MongoDB compass
- MongoDB Compass is an official graphical user interface for MongoDB so leave this checkbox as checked
- Click Next so now the installation of MongoDB will start
- After the installation of MongoDB is successfully finished you will see this window it says completed the MongoDB
- It will ask you to click the finish button so click the finish button
- Now once the MongoDB is installed on our Windows operating system
- Go to the location where MongoDB is installed
- Just go to your C directory and then Program Files and you will be able to see this MongoDB folder here
- Click on server and then click on whatever version of MongoDB you have installed there will be a folder created with that version name
- Click on this version name and then you will be able to see all these files and folders here
- Now click on the bin folder and here you will find all the MongoDB related executable files
- To start MongoDB you need to run this file which is Mongo D
- in order to open the MongoDB client you need to run this file which is Mongo
- Just copy this part here so in order to run the Mongo D command start the command prompt
- so just right-click on windows icon and then choose command prompt which is going to start the command prompt
- Go to CD to the folder where this Mongo D andMongo files are there so CD and paste
- The part you have copied for this bin folder and then press Enter
- Inside this bin folder, all these files are located
- Go inside this bin folder and here you just need to run this Mongo D command
- Just run Mongo D and then press Enter
- Which is going to start the MongoDB server
- 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
- so we need to create data directory and inside this data directory, create the DB directory in order to run this Mongo D command
- Go to the C directory and here create a new directory with the name data
- Inside this data, directory create a new directory with the name DB
- Just create the new directory with the name DB now this folder path is existing on Windows operating system
- 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
- 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
- and once again goto CD to the directory where Mongo and Mongo D executable files are there
- Once again CD to the bin directory of MongoDB
- And run the Mongo command so just give this command which is Mongo and then press ENTER
- Which is going to open the Mongo shell
- In order to show all the databases which are already there you just give this command show DB’s
- Which is going to show you all the default databases which are already existing inside your MongoDB
- Now in order to create a new database using MongoDB, you use this command use and the name of your database
- Let’s say I want to create a database called my Lib
- Just give the name of your database after use and this is going to create this database
- 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
- In order to insert some data you just need to give this command
- 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
- 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
- Let’s say the key name is name and then colon so for example the value is MongoDB book and press Enter
- A collection will be created and insert this document into your collection and once again when you give this show DBS command
- 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
- show collections and then the semicolon and then press ENTER
- which is going to show all the collections which are present inside your database
- 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
- So DB dot books and then give the find command in order to list all the equipments inside the collection
- 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
- Whenever you need to use the Mongo client you always need to start the Mongo daemon on the other shell so let
- In order to recognize your Mongo D command or Mongo command from anywhere, you need to set the environment variable for the MongoDB