Mongo DB Session 01 Document
Mongo DB Session 01 Document
Page 1 of 10
Topics Covered
Page 2 of 10
Introduction to Mongo DB
Our MongoDB tutorial includes all topics of MongoDB database such as insert documents,
update documents, delete documents, query documents, projection, sort() and limit() methods,
create a collection, drop collection, etc. There are also given MongoDB interview questions to
help you better understand the MongoDB database.
At the present time, the internet is loaded with big data, big users, big complexity etc. and also
becoming more complex day by day. NoSQL is answer of all these problems, It is not a
traditional database management system, not even a relational database management system
(RDBMS). NoSQL stands for "Not Only SQL". NoSQL is a type of database that can handle and
sort all type of unstructured, messy and complicated data. It is just a new way to think about
the database.
What is MongoDB
In simple words, you can say that - Mongo DB is a document-oriented database. It is an open
source product, developed and supported by a company named 10gen.
MongoDB is available under General Public license for free, and it is also available under
Commercial license from the manufacturer.
MongoDB was designed to work with commodity servers. Now it is used by the company of all
sizes, across all industry.
MonggoDB provides official driver support for C, C++, C#, Java, Node.js, Perl, PHP, Python,
Ruby, Scala, Go and Erlang.
You can use MongoDB with any of the above languages. There are some other community
supported drivers too but the above mentioned ones are officially provided by MongoDB.
Page 3 of 10
History of MongoDB
The initial development of MongoDB began in 2007 when the company was building a platform
as a service similar to window azure.
Window azure is a cloud computing platform and infrastructure, created by Microsoft, to build,
deploy and manage applications and service through a global network.
MongoDB was developed by a NewYork based organization named 10gen which is now known
as MongoDB Inc. It was initially developed as a PAAS (Platform as a Service). Later in 2009, it is
introduced in the market as an open source database server that was maintained and supported
by MongoDB Inc.
The first ready production of MongoDB has been considered from version 1.4 which was
released in March 2010.
It may be a very genuine question that - "what was the need of MongoDB although there were
many databases in action?"
All the modern applications require big data, fast features development, flexible deployment,
and the older database systems not competent enough, so the MongoDB was needed.
o Scalability
o Performance
o High Availability
o Scaling from single server deployments to large, complex multi-site architectures.
o Key points of MongoDB
o Develop Faster
o Deploy Easier
Page 4 of 10
o Scale Bigger
1. FirstName = "John",
2. Address = "Detroit",
3. Spouse = [{Name: "Angela"}].
4. FirstName ="John",
5. Address = "Wick"
Mongo DB falls into a class of databases that calls Document Oriented Databases. There is also a
broad category of database known as No SQL Databases.
Features of MongoDB
In MongoDB, you can search by field, range query and it also supports regular expression
searches.
2. Indexing
3. Replication
Page 5 of 10
A master can perform Reads and Writes and a Slave copies data from the master and can only
be used for reads or back up (not writes)
4. Duplication of data
MongoDB can run over multiple servers. The data is duplicated to keep the system up and also
keep its running condition in case of hardware failure.
5. Load balancing
7. Uses JavaScript instead of Procedures.
10. Stores files of any size easily without complicating your stack.
Now a day many companies using MongoDB to create new types of applications, improve
performance and availability.
NoSQL Databases
We know that MongoDB is a NoSQL Database, so it is very necessary to know about NoSQL
Database to understand MongoDB throughly.
Page 6 of 10
1. RDBMS (Relational Database Management System)
2. OLAP (Online Analytical Processing)
3. NoSQL (recently developed database)
NoSQL Database
It provides a mechanism for storage and retrieval of data other than tabular relations model
used in relational databases. NoSQL database doesn't use tables for storing data. It is generally
used to store big data and real-time web applications.
In the early 1970, Flat File Systems are used. Data were stored in flat files and the biggest
problems with flat files are each company implement their own flat files and there are no
standards. It is very difficult to store data in the files, retrieve data from files because there is no
standard way to store data.
Then the relational database was created by E.F. Codd and these databases answered the
question of having no standard way to store data. But later relational database also get a
problem that it could not handle big data, due to this problem there was a need of database
which can handle every types of problems then NoSQL database was developed.
Advantages of NoSQL
o It supports query language.
o It provides fast performance.
o It provides horizontal scalability.
In recent days, MongoDB is a new and popularly used database. It is a document based, non
relational database provider.
Although it is 100 times faster than the traditional database but it is early to say that it will
broadly replace the traditional RDBMS. But it may be very useful in term to gain performance
and scalability.
A Relational database has a typical schema design that shows number of tables and the
relationship between these tables, while in MongoDB there is no concept of relationship.
Page 7 of 10
MongoDB Advantages
o MongoDB is schema less. It is a document database in which one collection holds
different documents.
o There may be difference between number of fields, content and size of the
document from one to other.
o Structure of a single object is clear in MongoDB.
o There are no complex joins in MongoDB.
o MongoDB provides the facility of deep query because it supports a powerful dynamic
query on documents.
o It is very easy to scale.
o It uses internal memory for storing working sets and this is the reason of its fast access.
MongoDB Datatypes
Page 8 of 10
Data Types Description
String String is the most commonly used datatype. It is used to store data. A string
must be UTF 8 valid in mongodb.
Integer Integer is used to store the numeric value. It can be 32 bit or 64 bit
depending on the server you are using.
Boolean This datatype is used to store boolean values. It just shows YES/NO values.
Min/Max This datatype compare a value against the lowest and highest bson
Keys elements.
Arrays This datatype is used to store a list or multiple values into a single key.
Date This datatype stores the current date or time in unix time format. It makes
you possible to specify your own date time by creating object of date and
pass the value of date, month, year into it.
Session I
Page 9 of 10
3) Which are the different languages supported by MongoDB?
4) What is the purpose of building MongoDB?
5) Explain about document oriented database?
6) What are the futures of MongoDB?
7) What is NoSQL Database?
8) How many types of NoSQL Database?
9) What are the advantages of NoSQL?
10) What are the advantages of MongoDB?
11) What are the Distinctive advantages of MongoDB?
12) Where MongoDB Should be used?
13) Performance analysis of MongoDB & RDBMS?
Page 10 of 10