SlideShare a Scribd company logo
3
Most read
7
Most read
Mongo db
Introduction
• Why No SQL
• The Different Types Of NoSQL Database
• Overview Of MongoDB
• Basic Operations In Mongo Shell
• More Concepts
Relational
The World Has Changed
Mongo db
Types of NoSQL Database
Key Value
Stores
Column
Stores
Graph
Stores
Multi-Model
Databases
Document Stores
MongoDb Document are Typed
String Fields
Nested Document
Array
Geo-spatial Coordinates
RDBMS Vs MongoDB Terminology
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
Column Field
Table Join Embedded Documents
Primary Key
Primary Key (Default key _id provided
by mongodb itself)
Why Document ?
• Dynamic schema
• Elimination of object
relational mapping layer
• Implicit demoralization of
the data for performance.
Basic Operations In Mongo Shell
Commands Use
>use db_name
This command create database with the name mydb, but not show
newly created database in database list until unless it have at least
one document in it
>db This command shows currently selected database
>show dbs This command shows database list
>db.dropDatabase() Drop the database currently in use
Basic Operations In Mongo Shell
Commands Use
>db.createCollection(Na
me,Options)
This create a new collection in database which is currently under use
example
db.createCollection("mycol", { capped : true, autoIndexID : true, size :
6142800, max : 10000 } )
>db.COLLECTION_NAM
E.drop()
This command use to drop collection from database currently in use
Basic Operations In Mongo Shell
Commands Use
>db.COLLECTION_NAM
E.insert(document)
This command insert single data/document in specifient collection
and if collection is not already exist it will create one.
>db.COLLECTION_NAM
E.insert([document]) This command use to insert multiple documents, in the form of array
*if we don't specify the _id parameter, then MongoDB assigns a unique ObjectId for this
document.
*_id: ObjectId(4 bytes timestamp, 3 bytes machine id, 2 bytes process id, 3 bytes incrementer)
Basic Operations In Mongo Shell
Commands Use
>db.COLLECTION_NAME.update(S
ELECTION_CRITERIA,
UPDATED_DATA)
This command updates the values in the existing
document
>db.COLLECTION_NAME.save({_id
:ObjectId(),NEW_DATA})
This command replaces the existing document with the
document passed in save() method.
>db.COLLECTION_NAME.remove(
DELLETION_CRITTERIA)
Remove all the documents with deletion criteria
>db.COLLECTION_NAME.remove(
DELETION_CRITERIA,1)
If there are multiple records and you want to delete only
the first record, then set justOne parameter in remove()
method.
Basic Operations In Mongo Shell
Commands Use
>db.mycol.remove()
If you don't specify deletion criteria, then MongoDB will
delete whole documents from the collection.
>db.mycol.find().pretty()
To query data from MongoDB collection, you need to use
MongoDB's find() method. To display the results in a
formatted way, you can use pretty() method.
>db.mycol.find( { $and: [ {key1:
value1}, {key2:value2} ] } ).pretty()
In the find() method, if you pass multiple keys by
separating them by ',' then MongoDB treats it
as AND condition.
>db.mycol.find( { $or: [ {key1:
value1}, {key2:value2} ] } ).pretty()
To query documents based on the OR condition, you
need to use $or keyword.
Basic Operations In Mongo Shell
Commands Use
>db.mycol.createIndex({"title":1,"des
cription":-1})
This command pass multiple fields, to create index on
multiple fields.
>db.COLLECTION_NAME.find({},{K
EY:1})
In MongoDB, when you execute find() method, then it
displays all fields of a document. To limit this, you need to
set a list of fields with value 1 or 0. 1 is used to show the
field while 0 is used to hide the fields.
>db.COLLECTION_NAME.createInd
ex({"title":1})
This command is use for giving index to specified field
Embedded Relationships
{
“name": “Nouman Ellahi",
“title": “Software engineer",
"address_ids": [123, 1234]
}
( [ { "_id": 123,
"area": "G9/4",
"city": "Islamabad",
"state": "Pakistan“ },
{ "_id": 1234,
"area": "Wapda Town",
"city": "Chicago",
"state": "Pakistan“ } ] )
Address Collection
Employee Collection
More Concepts
• Replica set
• Sharding
• Aggregation
• GridFS
References and Recommended Readings
• https://www.mongodb.com/presentations/back-to-basics-webinar-1-
introduction-to-nosql
• https://www.tutorialspoint.com/mongodb/index.htm
• http://mongodb.github.io/mongo-java-driver/3.4/driver/getting-
started/quick-start/
• https://docs.mongodb.com/manual/
• https://docs.mongodb.com/getting-started/node/insert/

More Related Content

What's hot (20)

PPTX
Mongo db
Raghu nath
 
PPTX
Introduction to MongoDB
NodeXperts
 
PPTX
Mongo DB 102
Abhijeet Vaikar
 
PPTX
Basics of MongoDB
HabileLabs
 
PDF
Mongo db basics
Harischandra M K
 
PPTX
Mongo DB Presentation
Jaya Naresh Kovela
 
PDF
Mongo db basics
Claudio Montoya
 
PPTX
Connecting NodeJS & MongoDB
Enoch Joshua
 
PPTX
MongoDB basics & Introduction
Jerwin Roy
 
PDF
Introduction to MongoDB
Mike Dirolf
 
PPTX
Mongo db
Akshay Mathur
 
PPTX
Mongodb basics and architecture
Bishal Khanal
 
PDF
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
ODP
Introduction to MongoDB
Dineesha Suraweera
 
PPTX
The Basics of MongoDB
valuebound
 
PPTX
Mongodb - NoSql Database
Prashant Gupta
 
PPTX
MongoDB 101
Abhijeet Vaikar
 
PPTX
Mongo db operations_v2
Thanabalan Sathneeganandan
 
PDF
Mongo DB
Edureka!
 
PDF
Mongo db dhruba
Dhrubaji Mandal ♛
 
Mongo db
Raghu nath
 
Introduction to MongoDB
NodeXperts
 
Mongo DB 102
Abhijeet Vaikar
 
Basics of MongoDB
HabileLabs
 
Mongo db basics
Harischandra M K
 
Mongo DB Presentation
Jaya Naresh Kovela
 
Mongo db basics
Claudio Montoya
 
Connecting NodeJS & MongoDB
Enoch Joshua
 
MongoDB basics & Introduction
Jerwin Roy
 
Introduction to MongoDB
Mike Dirolf
 
Mongo db
Akshay Mathur
 
Mongodb basics and architecture
Bishal Khanal
 
MongoDB for Coder Training (Coding Serbia 2013)
Uwe Printz
 
Introduction to MongoDB
Dineesha Suraweera
 
The Basics of MongoDB
valuebound
 
Mongodb - NoSql Database
Prashant Gupta
 
MongoDB 101
Abhijeet Vaikar
 
Mongo db operations_v2
Thanabalan Sathneeganandan
 
Mongo DB
Edureka!
 
Mongo db dhruba
Dhrubaji Mandal ♛
 

Viewers also liked (18)

PPTX
Mongo DB
Karan Kukreja
 
PDF
Intro To MongoDB
Alex Sharp
 
PPT
Introduction to MongoDB
Ravi Teja
 
PPTX
Mongo db
Edmilson Neto
 
KEY
Administration (Eliot Horowitz)
MongoSF
 
PPTX
MediaGlu and Mongo DB
Sundar Nathikudi
 
PPT
Mongo db tutorials
Anuj Jain
 
PPTX
Shankar's mongo db presentation
Shankar Kamble
 
PPTX
Big data Career Opportunuties
Devashish Mishra
 
PPT
Broadcasting 3.0
Communication Research Centre
 
ODP
Introduction to MongoDB
Knoldus Inc.
 
PDF
Intro to NoSQL and MongoDB
MongoDB
 
PPTX
MongoDB
Tharun Srinivasa
 
KEY
An Evening with MongoDB - Orlando: Welcome and Keynote
MongoDB
 
PPTX
mongodb-brief-intro-february-2012
Chris Westin
 
KEY
Introduction to MongoDB
Sean Laurent
 
KEY
Mongodb intro
christkv
 
ODP
Seth Edwards on MongoDB
Skills Matter
 
Mongo DB
Karan Kukreja
 
Intro To MongoDB
Alex Sharp
 
Introduction to MongoDB
Ravi Teja
 
Mongo db
Edmilson Neto
 
Administration (Eliot Horowitz)
MongoSF
 
MediaGlu and Mongo DB
Sundar Nathikudi
 
Mongo db tutorials
Anuj Jain
 
Shankar's mongo db presentation
Shankar Kamble
 
Big data Career Opportunuties
Devashish Mishra
 
Introduction to MongoDB
Knoldus Inc.
 
Intro to NoSQL and MongoDB
MongoDB
 
An Evening with MongoDB - Orlando: Welcome and Keynote
MongoDB
 
mongodb-brief-intro-february-2012
Chris Westin
 
Introduction to MongoDB
Sean Laurent
 
Mongodb intro
christkv
 
Seth Edwards on MongoDB
Skills Matter
 
Ad

Similar to Mongo db (20)

PPT
Mongo db basics
Dhaval Mistry
 
PPTX
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
 
PPTX
Getting Started with MongoDB
Ahasanul Kalam Akib
 
PPTX
Introduction to MongoDB
S.Shayan Daneshvar
 
PPTX
lecture_34e.pptx
janibashashaik25
 
PPTX
fard car.pptx
tarungupta276841
 
PPTX
Mongodb Introduction
Nabeel Naqeebi
 
PDF
MongoDB NoSQL database a deep dive -MyWhitePaper
Rajesh Kumar
 
PPTX
MongoDB introduction features -presentation - 2.pptx
sampathkumar546444
 
PPTX
mongodb introduction11111111111111111111
VADAPALLYPRAVEENKUMA1
 
ODP
Mongo db rev001.
Rich Helton
 
DOCX
unit 4,Indexes in database.docx
RaviRajput416403
 
PPTX
How to learn MongoDB for beginner's
surajkumartpoint
 
PPTX
Introduction to MongoDB – A NoSQL Database
manikgupta2k04
 
PPTX
mongo.pptx
tarungupta276841
 
KEY
London MongoDB User Group April 2011
Rainforest QA
 
PPTX
MongoDbPpt based on python installation.
jnvcomputerlab2024
 
PPT
mongodb crud operations with detailed.ppt
karthik761
 
PDF
Quick overview on mongo db
Eman Mohamed
 
PPTX
Introduction To MongoDB
ElieHannouch
 
Mongo db basics
Dhaval Mistry
 
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
 
Getting Started with MongoDB
Ahasanul Kalam Akib
 
Introduction to MongoDB
S.Shayan Daneshvar
 
lecture_34e.pptx
janibashashaik25
 
fard car.pptx
tarungupta276841
 
Mongodb Introduction
Nabeel Naqeebi
 
MongoDB NoSQL database a deep dive -MyWhitePaper
Rajesh Kumar
 
MongoDB introduction features -presentation - 2.pptx
sampathkumar546444
 
mongodb introduction11111111111111111111
VADAPALLYPRAVEENKUMA1
 
Mongo db rev001.
Rich Helton
 
unit 4,Indexes in database.docx
RaviRajput416403
 
How to learn MongoDB for beginner's
surajkumartpoint
 
Introduction to MongoDB – A NoSQL Database
manikgupta2k04
 
mongo.pptx
tarungupta276841
 
London MongoDB User Group April 2011
Rainforest QA
 
MongoDbPpt based on python installation.
jnvcomputerlab2024
 
mongodb crud operations with detailed.ppt
karthik761
 
Quick overview on mongo db
Eman Mohamed
 
Introduction To MongoDB
ElieHannouch
 
Ad

Recently uploaded (20)

PDF
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PPTX
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
PDF
UNISE-Operation-Procedure-InDHIS2trainng
ahmedabduselam23
 
PDF
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
PPTX
05_Jelle Baats_Tekst.pptx_AI_Barometer_Release_Event
FinTech Belgium
 
PDF
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
PPTX
办理学历认证InformaticsLetter新加坡英华美学院毕业证书,Informatics成绩单
Taqyea
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
PPTX
01_Nico Vincent_Sailpeak.pptx_AI_Barometer_2025
FinTech Belgium
 
PDF
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
PPTX
美国史蒂文斯理工学院毕业证书{SIT学费发票SIT录取通知书}哪里购买
Taqyea
 
PDF
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PPTX
What Is Data Integration and Transformation?
subhashenia
 
PDF
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
PPTX
How to Add Columns and Rows in an R Data Frame
subhashenia
 
PDF
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
PPTX
Comparative Study of ML Techniques for RealTime Credit Card Fraud Detection S...
Debolina Ghosh
 
Optimizing Large Language Models with vLLM and Related Tools.pdf
Tamanna36
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
Aict presentation on dpplppp sjdhfh.pptx
vabaso5932
 
UNISE-Operation-Procedure-InDHIS2trainng
ahmedabduselam23
 
apidays Singapore 2025 - From API Intelligence to API Governance by Harsha Ch...
apidays
 
05_Jelle Baats_Tekst.pptx_AI_Barometer_Release_Event
FinTech Belgium
 
Data Science Course Certificate by Sigma Software University
Stepan Kalika
 
办理学历认证InformaticsLetter新加坡英华美学院毕业证书,Informatics成绩单
Taqyea
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
01_Nico Vincent_Sailpeak.pptx_AI_Barometer_2025
FinTech Belgium
 
apidays Singapore 2025 - Building a Federated Future, Alex Szomora (GSMA)
apidays
 
美国史蒂文斯理工学院毕业证书{SIT学费发票SIT录取通知书}哪里购买
Taqyea
 
NIS2 Compliance for MSPs: Roadmap, Benefits & Cybersecurity Trends (2025 Guide)
GRC Kompas
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
What Is Data Integration and Transformation?
subhashenia
 
The Best NVIDIA GPUs for LLM Inference in 2025.pdf
Tamanna36
 
How to Add Columns and Rows in an R Data Frame
subhashenia
 
Technical-Report-GPS_GIS_RS-for-MSF-finalv2.pdf
KPycho
 
Comparative Study of ML Techniques for RealTime Credit Card Fraud Detection S...
Debolina Ghosh
 

Mongo db

  • 2. Introduction • Why No SQL • The Different Types Of NoSQL Database • Overview Of MongoDB • Basic Operations In Mongo Shell • More Concepts
  • 4. The World Has Changed
  • 6. Types of NoSQL Database Key Value Stores Column Stores Graph Stores Multi-Model Databases Document Stores
  • 7. MongoDb Document are Typed String Fields Nested Document Array Geo-spatial Coordinates
  • 8. RDBMS Vs MongoDB Terminology RDBMS MongoDB Database Database Table Collection Tuple/Row Document Column Field Table Join Embedded Documents Primary Key Primary Key (Default key _id provided by mongodb itself)
  • 9. Why Document ? • Dynamic schema • Elimination of object relational mapping layer • Implicit demoralization of the data for performance.
  • 10. Basic Operations In Mongo Shell Commands Use >use db_name This command create database with the name mydb, but not show newly created database in database list until unless it have at least one document in it >db This command shows currently selected database >show dbs This command shows database list >db.dropDatabase() Drop the database currently in use
  • 11. Basic Operations In Mongo Shell Commands Use >db.createCollection(Na me,Options) This create a new collection in database which is currently under use example db.createCollection("mycol", { capped : true, autoIndexID : true, size : 6142800, max : 10000 } ) >db.COLLECTION_NAM E.drop() This command use to drop collection from database currently in use
  • 12. Basic Operations In Mongo Shell Commands Use >db.COLLECTION_NAM E.insert(document) This command insert single data/document in specifient collection and if collection is not already exist it will create one. >db.COLLECTION_NAM E.insert([document]) This command use to insert multiple documents, in the form of array *if we don't specify the _id parameter, then MongoDB assigns a unique ObjectId for this document. *_id: ObjectId(4 bytes timestamp, 3 bytes machine id, 2 bytes process id, 3 bytes incrementer)
  • 13. Basic Operations In Mongo Shell Commands Use >db.COLLECTION_NAME.update(S ELECTION_CRITERIA, UPDATED_DATA) This command updates the values in the existing document >db.COLLECTION_NAME.save({_id :ObjectId(),NEW_DATA}) This command replaces the existing document with the document passed in save() method. >db.COLLECTION_NAME.remove( DELLETION_CRITTERIA) Remove all the documents with deletion criteria >db.COLLECTION_NAME.remove( DELETION_CRITERIA,1) If there are multiple records and you want to delete only the first record, then set justOne parameter in remove() method.
  • 14. Basic Operations In Mongo Shell Commands Use >db.mycol.remove() If you don't specify deletion criteria, then MongoDB will delete whole documents from the collection. >db.mycol.find().pretty() To query data from MongoDB collection, you need to use MongoDB's find() method. To display the results in a formatted way, you can use pretty() method. >db.mycol.find( { $and: [ {key1: value1}, {key2:value2} ] } ).pretty() In the find() method, if you pass multiple keys by separating them by ',' then MongoDB treats it as AND condition. >db.mycol.find( { $or: [ {key1: value1}, {key2:value2} ] } ).pretty() To query documents based on the OR condition, you need to use $or keyword.
  • 15. Basic Operations In Mongo Shell Commands Use >db.mycol.createIndex({"title":1,"des cription":-1}) This command pass multiple fields, to create index on multiple fields. >db.COLLECTION_NAME.find({},{K EY:1}) In MongoDB, when you execute find() method, then it displays all fields of a document. To limit this, you need to set a list of fields with value 1 or 0. 1 is used to show the field while 0 is used to hide the fields. >db.COLLECTION_NAME.createInd ex({"title":1}) This command is use for giving index to specified field
  • 16. Embedded Relationships { “name": “Nouman Ellahi", “title": “Software engineer", "address_ids": [123, 1234] } ( [ { "_id": 123, "area": "G9/4", "city": "Islamabad", "state": "Pakistan“ }, { "_id": 1234, "area": "Wapda Town", "city": "Chicago", "state": "Pakistan“ } ] ) Address Collection Employee Collection
  • 17. More Concepts • Replica set • Sharding • Aggregation • GridFS
  • 18. References and Recommended Readings • https://www.mongodb.com/presentations/back-to-basics-webinar-1- introduction-to-nosql • https://www.tutorialspoint.com/mongodb/index.htm • http://mongodb.github.io/mongo-java-driver/3.4/driver/getting- started/quick-start/ • https://docs.mongodb.com/manual/ • https://docs.mongodb.com/getting-started/node/insert/