SlideShare a Scribd company logo
Introduction to MongoDB
Dr.A.Neela Madheswari,
Associate Professor,
Dept. of Computer Science and Engg,
Mahendra Engineering College,
Namakkal.
01/06/19 Introduction to MongoDB 1
2
Contents

MongoDB and Big Data

What is mongodb?

NoSQL

Where to use MongoDB?

Comparison of RDBMS & MongoDB

Database, Collection, Document

Installing MongoDB

Few commands and data types in MongoDB

Essential commands with screen shots
01/06/19 Introduction to MongoDB
3
MongoDB and Big Data
What makes data big?
Today data is being collected from different sources
and warehoused to perform analysis.
Different sources of data
Web data, E-commerce
Purchases at different stores
Bank/Credit card transactions
Social Network media
Every day 2.5 quintillion (10 to power of 18)bytes of
data generated.
90% of data we have today has been generated
from last two years01/06/19 Introduction to MongoDB
4
Who is generating Big data?
01/06/19 Introduction to MongoDB
5
Walmart handles more than 1 million customer
transactions every hour
Facebook handles 40 billion photos from its user base
Decoding the human genome originally took 10 years
to process; now it can be achieved in one week
01/06/19 Introduction to MongoDB
6
What is Hadoop?
Flexible architecture for large scale computation
and data processing on a network of
commodity hardware
Used for:
• Log processing
• Recommendation systems
• Analytics
• Video and image analysis
• Data retention
• etc
01/06/19 Introduction to MongoDB
7
MongoDB in Hadoop
01/06/19 Introduction to MongoDB
8
What is mongodb?

Document oriented database that provides
− High performance
− High availability
− Easy scalability

Open source

Leading NoSQL database

Written in C++

Creator: 10gen
01/06/19 Introduction to MongoDB
9
Non-relational data store
Does not store data in table
Stores data as a BSON document
BSON – Binary form of JSON
Stores data as a collection of key-value pair
Schema less
It means collection can have documents with
different shapes. Example:
• { “a”: 1, “b”: 2},
• {“a”: 1}
01/06/19 Introduction to MongoDB
10
NoSQL
Not only SQL
Non-relational, distributed, open-source and
horizontally scalable
Started in 2009 and growing rapidly
Characteristics:
Schema-free
Store huge amount of data
Currently more than 156 NoSQL databases
01/06/19 Introduction to MongoDB
11
NoSQL Databases categories
01/06/19 Introduction to MongoDB
1201/06/19 Introduction to MongoDB
13
Where to use mongodb?

Big data

Content management and Delivery

Mobile and Social Infrastructure

User data management

Data Hub
01/06/19 Introduction to MongoDB
14
Comparison of RDBMS & MongoDB
RDBMS Mongodb
Database Database
Table Collection
Tuple/Row Document
Column Field
Database Server and Client
Mysqld/Oracle mongod
mysql/sqlplus mongo
01/06/19 Introduction to MongoDB
15
Database

Database is a physical container for
collections.

Each database gets its own set of files on
the file system.

A single MongoDB server has multiple
databases.
01/06/19 Introduction to MongoDB
16
Collection

Collection is a group of MongoDB
documents.

It is the equivalent of an RDBMS table.

A collection exists within a single
database.

Collections do not enforce a schema.

Documents within a collection can have
different fields.

Typically, all documents in a collection are
of similar or related purpose.
01/06/19 Introduction to MongoDB
17
Document

A document is a set of key-value pairs.

Documents have dynamic schema.

Dynamic schema means that:
– documents in the same collection do not
need to have the same set of fields or
structure
– common fields in a collection's documents
may hold different types of data.
01/06/19 Introduction to MongoDB
1801/06/19 Introduction to MongoDB
19
Installing mongodb
01/06/19 Introduction to MongoDB
20
Steps for installing mongodb
1. Downloading the software and installing in
our system
2. Configuring system environment
3. Running mongodb
01/06/19 Introduction to MongoDB
21
1. Downloading the software and installing in
our system
01/06/19 Introduction to MongoDB
22
1. download the mongodb software i.e. msi file from the url
below:
https://www.mongodb.com/download-center#community
the downloaded software is: mongodb-win32-x86_64-
2008plus-ssl-3.2.10-signed.msi
2. Double click the .msi file to install.
3. Select Next button in Setup dialog box.
4. Accept the terms and conditions and select Next button.
5. Select setup type as Complete and click Next button.
6. Click Install button and then select Finish button.
7. Now a folder is created in the system with path:
C:Program FilesMongoDBServer3.2bin
01/06/19 Introduction to MongoDB
2301/06/19 Introduction to MongoDB
24
2. Configuring system environment
01/06/19 Introduction to MongoDB
25
1. MongoDB needs data directory to store all data. The
default path for data directory is: C:datadb
Hence create a folder with path as: C:datadb
2. Set the system environment path variable by right click
the My Computer or This PC icon on the Desktop ->
Select Advanced system settings -> Select Environment
variables -> In the system variables, select Path -> Click
Edit button -> Add the path at the end as: ;C:Program
FilesMongoDBServer3.2bin;
3. Now we can execute MongoDB commands at any path in
our system
01/06/19 Introduction to MongoDB
2601/06/19 Introduction to MongoDB
2701/06/19 Introduction to MongoDB
2801/06/19 Introduction to MongoDB
2901/06/19 Introduction to MongoDB
3001/06/19 Introduction to MongoDB
3101/06/19 Introduction to MongoDB
32
3. Running mongodb
01/06/19 Introduction to MongoDB
33
1. Go to cmd prompt and type as: mongod
Now the mongodb server has been started
on port 27017
2. Open another cmd prompt and type as:
mongo
Now we connected with mongodb server
with the database named test
01/06/19 Introduction to MongoDB
3401/06/19 Introduction to MongoDB
3501/06/19 Introduction to MongoDB
36
Commands - Help
To get commands, type as db.help() in client
01/06/19 Introduction to MongoDB
37
Mongodb Statistics
To get statistics about mongodb, type the
command db.stats() in client
01/06/19 Introduction to MongoDB
38
MongoDB Data types
S.No Data type Explanation
1 String String in MongoDB must be UTF-8
2 Integer Integer can be 32 bit or 64 bit depending upon our
server
3 Boolean To store values (true/false)
4 Double Store floating point values
5 Min/Max
keys
Used to compare a value against the lowest and
highest BSON elements
6 Arrays Used to store arrays or list or multiple values
7 Timestamp For recording when the document has been modified
8 Object Used for embedded documents
9 Null Used to store a Null value
10 Symbol Used to specify symbol type
11 Date Used to store current date or time in UNIX time format
12 Object ID Used to store document's ID
13 Binary data Used to store binary data
14 Code Used to store javascript code into the document
15 Regular
Expression
Used to store regular expression
01/06/19 Introduction to MongoDB
39
Essential Commands
1. Database
a) Create Database
b) Delete Database
2. Collection
a) Create collection
b) Drop collection
3. Document
a) Insert document
b) Query document
c) Update document
d) Remove document
01/06/19 Introduction to MongoDB
40
1.a) Create Database
Syntax:
use database_name
Example:
>use mydb
switched to db mydb
To check currently selected database, use the command db
>db
mydb
01/06/19 Introduction to MongoDB
4101/06/19 Introduction to MongoDB
42
To check the databases list, use the
command show dbs
>show dbs
01/06/19 Introduction to MongoDB
43
The databases mydb and test are not listed
To display the database, we need to insert
atleast one document into it.
In Mongodb, the default database is test.
If we dont create any database, the
collections will be stored in test database
01/06/19 Introduction to MongoDB
44
1.b) Delete Database
Syntax:
db.dropDatabase()
Example:
>use mydb
switched to db mydb
>db.dropDatabase()
>{ “dropped” : “mydb” , “ok” : 1 }
>
01/06/19 Introduction to MongoDB
45
2.a) Create Collection
Syntax:
db.createCollection(name, options)
Parameter Type Description
name String Name of the collection to be
created
options Document (optional) specify options
about memory size and
indexing
01/06/19 Introduction to MongoDB
4601/06/19 Introduction to MongoDB
47
2.b) Drop collection
Syntax:
db.collection_name.drop()
01/06/19 Introduction to MongoDB
48
3.a) Insert document
Syntax:
db.collection_name.insert(document)
01/06/19 Introduction to MongoDB
49
We can store multiple documents also at the
same time using insert() command like the
following.
01/06/19 Introduction to MongoDB
50
3.b) Query document
To query from MongoDB collection, we need
to use find() method.
Syntax:
db.collection_name.find()
This will display all the documents in a non-
structured way.
01/06/19 Introduction to MongoDB
5101/06/19 Introduction to MongoDB
52
To display the results in a formatted way,
pretty method is used.
Syntax:
db.collection_name.find().pretty()
01/06/19 Introduction to MongoDB
5301/06/19 Introduction to MongoDB
54
To return only one document, we have
findOne() method.
Syntax:
db.collection_name.findOne()
This will display the first document in the
given collection.
01/06/19 Introduction to MongoDB
5501/06/19 Introduction to MongoDB
56
3.c) Update document
The update() method is used to update the
values in the existing document.
Syntax:
db.collection_name.update(selection criteria,
updated data)
In the given example, the title is changed from 'MongoDB
Overview' to 'New MongoDB Tutorial' for title field.
By default, MongoDB will update only a single document. To
update multiple documents, we need to set a parameter
'multi' to true.01/06/19 Introduction to MongoDB
5701/06/19 Introduction to MongoDB
58
3.d) Remove document
remove() method is used to remove a
document from the collection.
Syntax:
db.collection_name.remove(deletion_criteria)
We can use deletion_criteria or justOne.
Both the values usage are optional only.
All the documents satisfying the given
criteria will be deleted.
01/06/19 Introduction to MongoDB
5901/06/19 Introduction to MongoDB
6001/06/19 Introduction to MongoDB
61
Across:
5. Used to find one document from given collection (7)
8. One of the NoSQL databases (7)
9. Database creation command (3)
10. Similar to table in MongoDB (10)
Down:
1. Mongodb server satrted with this port number (5)
2. Column family stores (5)
3. Set of key value pairs (8)
4. JavaScript Object Notation (4)
6. Not only SQL (5)
7. To get commands details (9)
11. Default database opened in MongoDB (4)01/06/19 Introduction to MongoDB
6201/06/19 Introduction to MongoDB
Online execution of queries
https://www.jdoodle.com/online-mongodb-terminal
01/06/19 Introduction to MongoDB 63
64
Thank You
01/06/19 Introduction to MongoDB
Ad

More Related Content

What's hot (20)

An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
Lee Theobald
 
Mongodb
MongodbMongodb
Mongodb
SARAVANAN GOPALAKRISHNAN
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Dineesha Suraweera
 
Mongo DB Presentation
Mongo DB PresentationMongo DB Presentation
Mongo DB Presentation
Jaya Naresh Kovela
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
Bishal Khanal
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
NodeXperts
 
Mongo db intro.pptx
Mongo db intro.pptxMongo db intro.pptx
Mongo db intro.pptx
JWORKS powered by Ordina
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
Hyphen Call
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
MongoDB
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
Prashant Gupta
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
César Trigo
 
Mongodb vs mysql
Mongodb vs mysqlMongodb vs mysql
Mongodb vs mysql
hemal sharma
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Mike Dirolf
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
Dhrubaji Mandal ♛
 
NoSql
NoSqlNoSql
NoSql
Girish Khanzode
 
MongoDB
MongoDBMongoDB
MongoDB
Anthony Slabinck
 
Introduction of ssis
Introduction of ssisIntroduction of ssis
Introduction of ssis
deepakk073
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented Databases
Fabio Fumarola
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
Ramakant Soni
 
Intro To MongoDB
Intro To MongoDBIntro To MongoDB
Intro To MongoDB
Alex Sharp
 

Similar to Introduction to mongodb (20)

Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
Vipin Mundayad
 
Experiment no 1
Experiment no 1Experiment no 1
Experiment no 1
Ankit Dubey
 
MongoDB
MongoDBMongoDB
MongoDB
wiTTyMinds1
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdf
sarah david
 
Mongo db report
Mongo db reportMongo db report
Mongo db report
Hyphen Call
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptx
sarah david
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
75waytechnologies
 
MongoDB classes 2019
MongoDB classes 2019MongoDB classes 2019
MongoDB classes 2019
Alexandre BERGERE
 
Mongo db
Mongo dbMongo db
Mongo db
Gyanendra Yadav
 
Mongo db
Mongo dbMongo db
Mongo db
AbhiKhurana8
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
Claudio Montoya
 
MongoDB DOC v1.5
MongoDB DOC v1.5MongoDB DOC v1.5
MongoDB DOC v1.5
Tharun Srinivasa
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
Enoch Joshua
 
A Study on Mongodb Database.pdf
A Study on Mongodb Database.pdfA Study on Mongodb Database.pdf
A Study on Mongodb Database.pdf
Jessica Navarro
 
A Study on Mongodb Database
A Study on Mongodb DatabaseA Study on Mongodb Database
A Study on Mongodb Database
IJSRD
 
Mongodb Introduction
Mongodb Introduction Mongodb Introduction
Mongodb Introduction
Nabeel Naqeebi
 
Mongodb
MongodbMongodb
Mongodb
Apurva Vyas
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
 
Mdb dn 2017_17_bi_connector2
Mdb dn 2017_17_bi_connector2Mdb dn 2017_17_bi_connector2
Mdb dn 2017_17_bi_connector2
Daniel M. Farrell
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
Marco Segato
 
how_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdfhow_can_businesses_address_storage_issues_using_mongodb.pdf
how_can_businesses_address_storage_issues_using_mongodb.pdf
sarah david
 
how_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptxhow_can_businesses_address_storage_issues_using_mongodb.pptx
how_can_businesses_address_storage_issues_using_mongodb.pptx
sarah david
 
Everything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptxEverything You Need to Know About MongoDB Development.pptx
Everything You Need to Know About MongoDB Development.pptx
75waytechnologies
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
Enoch Joshua
 
A Study on Mongodb Database.pdf
A Study on Mongodb Database.pdfA Study on Mongodb Database.pdf
A Study on Mongodb Database.pdf
Jessica Navarro
 
A Study on Mongodb Database
A Study on Mongodb DatabaseA Study on Mongodb Database
A Study on Mongodb Database
IJSRD
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
 
Mdb dn 2017_17_bi_connector2
Mdb dn 2017_17_bi_connector2Mdb dn 2017_17_bi_connector2
Mdb dn 2017_17_bi_connector2
Daniel M. Farrell
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
Marco Segato
 
Ad

Recently uploaded (20)

Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..
yuvarajreddy2002
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag
fardin123rahman07
 
Molecular methods diagnostic and monitoring of infection - Repaired.pptx
Molecular methods diagnostic and monitoring of infection  -  Repaired.pptxMolecular methods diagnostic and monitoring of infection  -  Repaired.pptx
Molecular methods diagnostic and monitoring of infection - Repaired.pptx
7tzn7x5kky
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
FPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptxFPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptx
ssuser4ef83d
 
Medical Dataset including visualizations
Medical Dataset including visualizationsMedical Dataset including visualizations
Medical Dataset including visualizations
vishrut8750588758
 
How to join illuminati Agent in uganda call+256776963507/0741506136
How to join illuminati Agent in uganda call+256776963507/0741506136How to join illuminati Agent in uganda call+256776963507/0741506136
How to join illuminati Agent in uganda call+256776963507/0741506136
illuminati Agent uganda call+256776963507/0741506136
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
James Francis Paradigm Asset Management
 
04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story
ccctableauusergroup
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbbEDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
JessaMaeEvangelista2
 
Deloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit contextDeloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit context
Process mining Evangelist
 
03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia
Alexander Romero Arosquipa
 
Defense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptxDefense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptx
Greg Makowski
 
Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...
Pixellion
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..
yuvarajreddy2002
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag
fardin123rahman07
 
Molecular methods diagnostic and monitoring of infection - Repaired.pptx
Molecular methods diagnostic and monitoring of infection  -  Repaired.pptxMolecular methods diagnostic and monitoring of infection  -  Repaired.pptx
Molecular methods diagnostic and monitoring of infection - Repaired.pptx
7tzn7x5kky
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
FPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptxFPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptx
ssuser4ef83d
 
Medical Dataset including visualizations
Medical Dataset including visualizationsMedical Dataset including visualizations
Medical Dataset including visualizations
vishrut8750588758
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
James Francis Paradigm Asset Management
 
04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story
ccctableauusergroup
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbbEDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
JessaMaeEvangelista2
 
Deloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit contextDeloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit context
Process mining Evangelist
 
Defense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptxDefense Against LLM Scheming 2025_04_28.pptx
Defense Against LLM Scheming 2025_04_28.pptx
Greg Makowski
 
Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...
Pixellion
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Ad

Introduction to mongodb

  • 1. Introduction to MongoDB Dr.A.Neela Madheswari, Associate Professor, Dept. of Computer Science and Engg, Mahendra Engineering College, Namakkal. 01/06/19 Introduction to MongoDB 1
  • 2. 2 Contents  MongoDB and Big Data  What is mongodb?  NoSQL  Where to use MongoDB?  Comparison of RDBMS & MongoDB  Database, Collection, Document  Installing MongoDB  Few commands and data types in MongoDB  Essential commands with screen shots 01/06/19 Introduction to MongoDB
  • 3. 3 MongoDB and Big Data What makes data big? Today data is being collected from different sources and warehoused to perform analysis. Different sources of data Web data, E-commerce Purchases at different stores Bank/Credit card transactions Social Network media Every day 2.5 quintillion (10 to power of 18)bytes of data generated. 90% of data we have today has been generated from last two years01/06/19 Introduction to MongoDB
  • 4. 4 Who is generating Big data? 01/06/19 Introduction to MongoDB
  • 5. 5 Walmart handles more than 1 million customer transactions every hour Facebook handles 40 billion photos from its user base Decoding the human genome originally took 10 years to process; now it can be achieved in one week 01/06/19 Introduction to MongoDB
  • 6. 6 What is Hadoop? Flexible architecture for large scale computation and data processing on a network of commodity hardware Used for: • Log processing • Recommendation systems • Analytics • Video and image analysis • Data retention • etc 01/06/19 Introduction to MongoDB
  • 7. 7 MongoDB in Hadoop 01/06/19 Introduction to MongoDB
  • 8. 8 What is mongodb?  Document oriented database that provides − High performance − High availability − Easy scalability  Open source  Leading NoSQL database  Written in C++  Creator: 10gen 01/06/19 Introduction to MongoDB
  • 9. 9 Non-relational data store Does not store data in table Stores data as a BSON document BSON – Binary form of JSON Stores data as a collection of key-value pair Schema less It means collection can have documents with different shapes. Example: • { “a”: 1, “b”: 2}, • {“a”: 1} 01/06/19 Introduction to MongoDB
  • 10. 10 NoSQL Not only SQL Non-relational, distributed, open-source and horizontally scalable Started in 2009 and growing rapidly Characteristics: Schema-free Store huge amount of data Currently more than 156 NoSQL databases 01/06/19 Introduction to MongoDB
  • 11. 11 NoSQL Databases categories 01/06/19 Introduction to MongoDB
  • 13. 13 Where to use mongodb?  Big data  Content management and Delivery  Mobile and Social Infrastructure  User data management  Data Hub 01/06/19 Introduction to MongoDB
  • 14. 14 Comparison of RDBMS & MongoDB RDBMS Mongodb Database Database Table Collection Tuple/Row Document Column Field Database Server and Client Mysqld/Oracle mongod mysql/sqlplus mongo 01/06/19 Introduction to MongoDB
  • 15. 15 Database  Database is a physical container for collections.  Each database gets its own set of files on the file system.  A single MongoDB server has multiple databases. 01/06/19 Introduction to MongoDB
  • 16. 16 Collection  Collection is a group of MongoDB documents.  It is the equivalent of an RDBMS table.  A collection exists within a single database.  Collections do not enforce a schema.  Documents within a collection can have different fields.  Typically, all documents in a collection are of similar or related purpose. 01/06/19 Introduction to MongoDB
  • 17. 17 Document  A document is a set of key-value pairs.  Documents have dynamic schema.  Dynamic schema means that: – documents in the same collection do not need to have the same set of fields or structure – common fields in a collection's documents may hold different types of data. 01/06/19 Introduction to MongoDB
  • 20. 20 Steps for installing mongodb 1. Downloading the software and installing in our system 2. Configuring system environment 3. Running mongodb 01/06/19 Introduction to MongoDB
  • 21. 21 1. Downloading the software and installing in our system 01/06/19 Introduction to MongoDB
  • 22. 22 1. download the mongodb software i.e. msi file from the url below: https://www.mongodb.com/download-center#community the downloaded software is: mongodb-win32-x86_64- 2008plus-ssl-3.2.10-signed.msi 2. Double click the .msi file to install. 3. Select Next button in Setup dialog box. 4. Accept the terms and conditions and select Next button. 5. Select setup type as Complete and click Next button. 6. Click Install button and then select Finish button. 7. Now a folder is created in the system with path: C:Program FilesMongoDBServer3.2bin 01/06/19 Introduction to MongoDB
  • 24. 24 2. Configuring system environment 01/06/19 Introduction to MongoDB
  • 25. 25 1. MongoDB needs data directory to store all data. The default path for data directory is: C:datadb Hence create a folder with path as: C:datadb 2. Set the system environment path variable by right click the My Computer or This PC icon on the Desktop -> Select Advanced system settings -> Select Environment variables -> In the system variables, select Path -> Click Edit button -> Add the path at the end as: ;C:Program FilesMongoDBServer3.2bin; 3. Now we can execute MongoDB commands at any path in our system 01/06/19 Introduction to MongoDB
  • 32. 32 3. Running mongodb 01/06/19 Introduction to MongoDB
  • 33. 33 1. Go to cmd prompt and type as: mongod Now the mongodb server has been started on port 27017 2. Open another cmd prompt and type as: mongo Now we connected with mongodb server with the database named test 01/06/19 Introduction to MongoDB
  • 36. 36 Commands - Help To get commands, type as db.help() in client 01/06/19 Introduction to MongoDB
  • 37. 37 Mongodb Statistics To get statistics about mongodb, type the command db.stats() in client 01/06/19 Introduction to MongoDB
  • 38. 38 MongoDB Data types S.No Data type Explanation 1 String String in MongoDB must be UTF-8 2 Integer Integer can be 32 bit or 64 bit depending upon our server 3 Boolean To store values (true/false) 4 Double Store floating point values 5 Min/Max keys Used to compare a value against the lowest and highest BSON elements 6 Arrays Used to store arrays or list or multiple values 7 Timestamp For recording when the document has been modified 8 Object Used for embedded documents 9 Null Used to store a Null value 10 Symbol Used to specify symbol type 11 Date Used to store current date or time in UNIX time format 12 Object ID Used to store document's ID 13 Binary data Used to store binary data 14 Code Used to store javascript code into the document 15 Regular Expression Used to store regular expression 01/06/19 Introduction to MongoDB
  • 39. 39 Essential Commands 1. Database a) Create Database b) Delete Database 2. Collection a) Create collection b) Drop collection 3. Document a) Insert document b) Query document c) Update document d) Remove document 01/06/19 Introduction to MongoDB
  • 40. 40 1.a) Create Database Syntax: use database_name Example: >use mydb switched to db mydb To check currently selected database, use the command db >db mydb 01/06/19 Introduction to MongoDB
  • 42. 42 To check the databases list, use the command show dbs >show dbs 01/06/19 Introduction to MongoDB
  • 43. 43 The databases mydb and test are not listed To display the database, we need to insert atleast one document into it. In Mongodb, the default database is test. If we dont create any database, the collections will be stored in test database 01/06/19 Introduction to MongoDB
  • 44. 44 1.b) Delete Database Syntax: db.dropDatabase() Example: >use mydb switched to db mydb >db.dropDatabase() >{ “dropped” : “mydb” , “ok” : 1 } > 01/06/19 Introduction to MongoDB
  • 45. 45 2.a) Create Collection Syntax: db.createCollection(name, options) Parameter Type Description name String Name of the collection to be created options Document (optional) specify options about memory size and indexing 01/06/19 Introduction to MongoDB
  • 49. 49 We can store multiple documents also at the same time using insert() command like the following. 01/06/19 Introduction to MongoDB
  • 50. 50 3.b) Query document To query from MongoDB collection, we need to use find() method. Syntax: db.collection_name.find() This will display all the documents in a non- structured way. 01/06/19 Introduction to MongoDB
  • 52. 52 To display the results in a formatted way, pretty method is used. Syntax: db.collection_name.find().pretty() 01/06/19 Introduction to MongoDB
  • 54. 54 To return only one document, we have findOne() method. Syntax: db.collection_name.findOne() This will display the first document in the given collection. 01/06/19 Introduction to MongoDB
  • 56. 56 3.c) Update document The update() method is used to update the values in the existing document. Syntax: db.collection_name.update(selection criteria, updated data) In the given example, the title is changed from 'MongoDB Overview' to 'New MongoDB Tutorial' for title field. By default, MongoDB will update only a single document. To update multiple documents, we need to set a parameter 'multi' to true.01/06/19 Introduction to MongoDB
  • 58. 58 3.d) Remove document remove() method is used to remove a document from the collection. Syntax: db.collection_name.remove(deletion_criteria) We can use deletion_criteria or justOne. Both the values usage are optional only. All the documents satisfying the given criteria will be deleted. 01/06/19 Introduction to MongoDB
  • 61. 61 Across: 5. Used to find one document from given collection (7) 8. One of the NoSQL databases (7) 9. Database creation command (3) 10. Similar to table in MongoDB (10) Down: 1. Mongodb server satrted with this port number (5) 2. Column family stores (5) 3. Set of key value pairs (8) 4. JavaScript Object Notation (4) 6. Not only SQL (5) 7. To get commands details (9) 11. Default database opened in MongoDB (4)01/06/19 Introduction to MongoDB
  • 63. Online execution of queries https://www.jdoodle.com/online-mongodb-terminal 01/06/19 Introduction to MongoDB 63