SlideShare a Scribd company logo
Mongo DB: Fundamentals & Basics
By Pawan
ļ‚§ We have INSTRUCTOR LED - both Online LIVE & Classroom Session
ļ‚§ Present for classroom sessions in Bangalore & Delhi (NCR)
ļ‚§ We are the ONLY Education delivery partners for Mulesoft, Elastic, Pivotal & Lightbend in India
ļ‚§ We have delivered more than 5000 trainings and have over 400 courses and a vast pool of over 200 experts to
make YOU the EXPERT!
FOLLOW US ON SOCIAL MEDIA TO STAY UPDATED ON THE UPCOMING WEBINARS
Online and Classroom Training on Technology Courses at
SpringPeople
Non-Certified Courses
…and many more
Certified Partners
What is MongoDB
 MongoDB is an open-source document database and leading NoSQL database
 Schema less
 Stores JSON objects
 document oriented database that provides
 high performance
 high availability
 easy scalability
7/28/2016Pawan Tiwari
Why MongoDB
 Document Oriented Storage: Data is stored in the form of JSON style
documents.
 Index on any attribute
 Geo Location support
 Replication and high availability
 Auto-sharding
 Rich queries
 Fast in-place updates
 Professional support by MongoDB
7/28/2016Pawan Tiwari
MongoDB Overview
 Database
 Physical Container of Collection
 Collections
 Collection is a group of MongoDB documents
 equivalent of an RDBMS table
 Collections do not enforce a schema.
 Document
 set of key-value pairs.
 Documents have dynamic schema
7/28/2016Pawan Tiwari
RDBMS and MongoDB
 Database  Database
 Table  Collection
 Row  Document
 Column  Field
7/28/2016Pawan Tiwari
Sample Document
{
_id: ObjectId(7df78ad8902c)
a: ā€˜1’,
b: ā€˜2’
}
7/28/2016Pawan Tiwari
Advantages of MongoDB
 Schema less
 Structure of a single object is clear.
 No complex joins.
 Supports dynamic queries on documents using a document-based query
language that's nearly as powerful as SQL.
 Tuning.
 Ease of scale-out: MongoDB is easy to scale.
 Conversion/mapping of application objects to database objects not needed.
 Uses internal memory for storing the (windowed) working set, enabling faster
access of data
7/28/2016Pawan Tiwari
Create Collection
 Db.createcollection(ā€œcollection_nameā€ Options)
 Example:
MongoDB shell version: 2.4.14
connecting to: test
> show dbs
local 0.078125GB
test 0.203125GB
> use test
switched to db test
> db.createCollection("test_collection")
{ "ok" : 1 }
>
7/28/2016Pawan Tiwari
Drop Collection
 db.COLLECTION_NAME.drop()
MongoDB shell version: 2.4.14
connecting to: test
> show collections
system.indexes
test_collection
> db.test_collection.drop()
true
7/28/2016Pawan Tiwari
Insert Document
 db.COLLECTION_NAME.insert(document)
>db.test_collection.insert({
title: 'MongoDB Webinar',
description: 'MongoDB is a high-performance, open source, schema- free,
document/object-oriented database optimized for web application environments, and
is perhaps one of the most disruptive software technologies in years. MongoDB will
fundamentally change the way participants think about data persistence. In this
webinar know the fundamentals of designing and building applications using
MongoDB',
by: 'SpringPeople',
url: 'http://www.springpeople.com/webinars/mongodb-developer-fundamentals-and-
basics',
})
7/28/2016Pawan Tiwari
Query Document
 db.COLLECTION_NAME.find(document)
Example:
>db.test_collection.find()
>db.test_collection.find().pretty()
>db.test_collection.find({"title" : "MongoDB Webinar"})
> db.test_collection.find({"title" : "MongoDB Webinar"},{"by":1}).pretty()
{ "_id" : ObjectId("5791d58760a74da5b3e51eb9"), "by" : "SpringPeople" }
> db.test_collection.find({"title" : "MongoDB Webinar"},{"by":1,_id:0}).pretty()
{ "by" : "SpringPeople" }
7/28/2016Pawan Tiwari
SQL vs Mongodb
SQL SELECT Statements MongoDB find() Statements
SELECT * FROM users db.users.find()
SELECT id, user_id, status FROM users db.users.find( { }, { user_id: 1, status: 1 } )
SELECT user_id, status FROM users db.users.find( { }, { user_id: 1, status: 1, _id: 0 } )
SELECT * FROM users WHERE status = "A" db.users.find( { status: "A" } )
SELECT user_id, status FROM users WHERE status = "A" db.users.find( { status: "A" }, { user_id: 1, status: 1, _id: 0 } )
SELECT * FROM users WHERE status != "A" db.users.find( { status: { $ne: "A" } } )
SELECT * FROM users WHERE status = "A" AND age = 50 db.users.find( { status: "A", age: 50 } )
SELECT * FROM users WHERE status = "A" OR age = 50 db.users.find( { $or: [ { status: "A" } , { age: 50 } ] } )
SELECT * FROM users WHERE age > 25 db.users.find( { age: { $gt: 25 } } )
7/28/2016Pawan Tiwari
SQL vs Mongodb
7/28/2016Pawan Tiwari
SELECT * FROM users WHERE age < 25 db.users.find( { age: { $lt: 25 } } )
SELECT * FROM users WHERE age > 25 AND age <= 50 db.users.find( { age: { $gt: 25, $lte: 50 } } )
SELECT * FROM users WHERE user_id like "%bc%" db.users.find( { user_id: /bc/ } )
SELECT * FROM users WHERE user_id like "bc%" db.users.find( { user_id: /^bc/ } )
SELECT * FROM users WHERE status = "A" ORDER BY user_id ASC db.users.find( { status: "A" } ).sort( { user_id: 1 } )
SELECT * FROM users WHERE status = "A" ORDER BY user_id DESC db.users.find( { status: "A" } ).sort( { user_id: -1 } )
SELECT COUNT(*) FROM users
db.users.count()
or
db.users.find().count()
SELECT COUNT(user_id) FROM users
db.users.count( { user_id: { $exists: true } } )
or
db.users.find( { user_id: { $exists: true } } ).count()
Usefull MongoDB commands
7/28/2016Pawan Tiwari
 Db.createcollection(users)
 Db.users.insert({ā€œnameā€: ā€œXYZā€})
 db.users.createIndex( { user_id: 1 } )
 db.users.update(
{ age: { $gt: 25 } },
{ $set: { status: "C" } },
{ multi: true }
)
 db.users.remove( { status: "D" } )
db.users.remove( { status:"D" } )
Thank You
7/28/2016Pawan Tiwari
www.springpeople.comtraining@springpeople.com
Upcoming Mongo DB Classes at SpringPeople
Classroom (Bengaluru) 16 - 18 Sept
Online LIVE 08 - 17 Aug

More Related Content

PDF
An introduction to MongoDB
PPTX
Introduction to MongoDB
PPTX
Basics of MongoDB
PDF
MongoDB- Crud Operation
PPTX
MongoDB presentation
PDF
MongoDB for Coder Training (Coding Serbia 2013)
PPTX
Mongodb basics and architecture
ODP
Introduction to MongoDB
An introduction to MongoDB
Introduction to MongoDB
Basics of MongoDB
MongoDB- Crud Operation
MongoDB presentation
MongoDB for Coder Training (Coding Serbia 2013)
Mongodb basics and architecture
Introduction to MongoDB

What's hot (20)

DOC
DB2 DOCUMENT
PPTX
Indexing with MongoDB
PPT
Introduction to mongodb
PPTX
MongoDB
PPTX
PostgreSQL Database Slides
PDF
MongoDB Fundamentals
PDF
GeoServer 2.4.x ᄒᅔᆫ국ᄋᅄ į„‰į…”į„‹į…­į†¼į„Œį…” į„Œį…µį„Žį…µį†·į„‰į…„
PPTX
Mongo DB Presentation
DOCX
MySQL_SQL_Tunning_v0.1.3.docx
PPTX
Relational databases vs Non-relational databases
PPTX
Mongo DB ģ„±ėŠ„ģµœģ ķ™” ģ „ėžµ
PPTX
Mongodb introduction and_internal(simple)
PPTX
Sql subquery
PDF
MongoDB performance
PDF
Mongodb ķŠ¹ģ§• ė¶„ģ„
PPTX
MongoDB 101
PPTX
Mongo db intro.pptx
PDF
How queries work with sharding
PPTX
PPTX
Big Data and Hadoop
DB2 DOCUMENT
Indexing with MongoDB
Introduction to mongodb
MongoDB
PostgreSQL Database Slides
MongoDB Fundamentals
GeoServer 2.4.x ᄒᅔᆫ국ᄋᅄ į„‰į…”į„‹į…­į†¼į„Œį…” į„Œį…µį„Žį…µį†·į„‰į…„
Mongo DB Presentation
MySQL_SQL_Tunning_v0.1.3.docx
Relational databases vs Non-relational databases
Mongo DB ģ„±ėŠ„ģµœģ ķ™” ģ „ėžµ
Mongodb introduction and_internal(simple)
Sql subquery
MongoDB performance
Mongodb ķŠ¹ģ§• ė¶„ģ„
MongoDB 101
Mongo db intro.pptx
How queries work with sharding
Big Data and Hadoop
Ad

Viewers also liked (20)

PPTX
MongoDB for Beginners
PPTX
Mongo DB
PDF
Intro To MongoDB
PDF
Mongo db
PDF
Mongo DB
PPT
Introduction to MongoDB
KEY
Getting Started with MongoDB and Node.js
PPTX
Connecting NodeJS & MongoDB
PPTX
Mongo db
PPTX
MongoDB-Beginner tutorial explaining basic operation via mongo shell
PDF
Introduction to MongoDB
PPTX
An Introduction To NoSQL & MongoDB
PPTX
Intro To Mongo Db
PDF
Introduction to mongo db
PDF
Business considerations for node.js applications
PPTX
PPTX
Mongo db
PPTX
Mongo db day seattle keynote
PDF
Introduction to mongo db by zain
MongoDB for Beginners
Mongo DB
Intro To MongoDB
Mongo db
Mongo DB
Introduction to MongoDB
Getting Started with MongoDB and Node.js
Connecting NodeJS & MongoDB
Mongo db
MongoDB-Beginner tutorial explaining basic operation via mongo shell
Introduction to MongoDB
An Introduction To NoSQL & MongoDB
Intro To Mongo Db
Introduction to mongo db
Business considerations for node.js applications
Mongo db
Mongo db day seattle keynote
Introduction to mongo db by zain
Ad

Similar to Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials (20)

PPTX
MongoDB Knowledge share
PPT
Mongo db basics
PDF
Data access
PDF
Java Web Programming Using Cloud Platform: Module 3
PPTX
MongoDB Workshop.pptx computer science and engineering
PPT
Jdbc drivers
PPTX
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
PDF
Java Web Programming [3/9] : Servlet Advanced
PPT
LSC - Synchronizing identities @ Loadays 2010
Ā 
PPTX
La sql
PPTX
Entity Framework Database and Code First
PPT
Overview on NoSQL and MongoDB
PDF
Slide perkenalan dengan dasar MongoDB-query
PPTX
NoSQL Endgame LWJUG 2021
PDF
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
ODP
LSC - Synchronizing identities @ Loadays 2010
PPTX
MongoDb Database Notes Presentation Latest
PDF
Introduction to MongoDB
PPTX
Microservices Primer for Monolithic Devs
PPTX
MongoDB - A next-generation database that lets you create applications never ...
MongoDB Knowledge share
Mongo db basics
Data access
Java Web Programming Using Cloud Platform: Module 3
MongoDB Workshop.pptx computer science and engineering
Jdbc drivers
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Java Web Programming [3/9] : Servlet Advanced
LSC - Synchronizing identities @ Loadays 2010
Ā 
La sql
Entity Framework Database and Code First
Overview on NoSQL and MongoDB
Slide perkenalan dengan dasar MongoDB-query
NoSQL Endgame LWJUG 2021
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
LSC - Synchronizing identities @ Loadays 2010
MongoDb Database Notes Presentation Latest
Introduction to MongoDB
Microservices Primer for Monolithic Devs
MongoDB - A next-generation database that lets you create applications never ...

More from SpringPeople (20)

PPTX
Growth hacking tips and tricks that you can try
PPTX
Top Big data Analytics tools: Emerging trends and Best practices
PPTX
Introduction to Big Data
PPTX
Introduction to Microsoft Azure IaaS
PPTX
Introduction to Selenium WebDriver
PPT
Introduction to Open stack - An Overview
PPTX
Best Practices for Administering Hadoop with Hortonworks Data Platform (HDP) ...
PPT
Why 2 million Developers depend on MuleSoft
PPTX
Mastering Test Automation: How To Use Selenium Successfully
PPTX
An Introduction of Big data; Big data for beginners; Overview of Big Data; Bi...
PDF
SpringPeople - Introduction to Cloud Computing
PDF
SpringPeople - Devops skills - Do you have what it takes?
PPTX
Elastic - ELK, Logstash & Kibana
PPTX
Hadoop data access layer v4.0
PDF
Introduction To Core Java - SpringPeople
PDF
Introduction To Hadoop Administration - SpringPeople
PDF
Introduction To Cloud Foundry - SpringPeople
PDF
Introduction To Spring Enterprise Integration - SpringPeople
PDF
Introduction To Groovy And Grails - SpringPeople
PDF
Introduction To Jenkins - SpringPeople
Growth hacking tips and tricks that you can try
Top Big data Analytics tools: Emerging trends and Best practices
Introduction to Big Data
Introduction to Microsoft Azure IaaS
Introduction to Selenium WebDriver
Introduction to Open stack - An Overview
Best Practices for Administering Hadoop with Hortonworks Data Platform (HDP) ...
Why 2 million Developers depend on MuleSoft
Mastering Test Automation: How To Use Selenium Successfully
An Introduction of Big data; Big data for beginners; Overview of Big Data; Bi...
SpringPeople - Introduction to Cloud Computing
SpringPeople - Devops skills - Do you have what it takes?
Elastic - ELK, Logstash & Kibana
Hadoop data access layer v4.0
Introduction To Core Java - SpringPeople
Introduction To Hadoop Administration - SpringPeople
Introduction To Cloud Foundry - SpringPeople
Introduction To Spring Enterprise Integration - SpringPeople
Introduction To Groovy And Grails - SpringPeople
Introduction To Jenkins - SpringPeople

Recently uploaded (20)

PDF
Doc9.....................................
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
Dell Pro 14 Plus: Be better prepared for what’s coming
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Ā 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
PDF
Software Development Methodologies in 2025
Ā 
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
PDF
Top Generative AI Tools for Patent Drafting in 2025.pdf
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
PDF
SparkLabs Primer on Artificial Intelligence 2025
PDF
Why Endpoint Security Is Critical in a Remote Work Era?
Doc9.....................................
Smarter Business Operations Powered by IoT Remote Monitoring
Dell Pro 14 Plus: Be better prepared for what’s coming
NewMind AI Weekly Chronicles - July'25 - Week IV
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Understanding_Digital_Forensics_Presentation.pptx
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Ā 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Software Development Methodologies in 2025
Ā 
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
Top Generative AI Tools for Patent Drafting in 2025.pdf
Reimagining Insurance: Connected Data for Confident Decisions.pdf
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
SparkLabs Primer on Artificial Intelligence 2025
Why Endpoint Security Is Critical in a Remote Work Era?

Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials

  • 1. Mongo DB: Fundamentals & Basics By Pawan
  • 2. ļ‚§ We have INSTRUCTOR LED - both Online LIVE & Classroom Session ļ‚§ Present for classroom sessions in Bangalore & Delhi (NCR) ļ‚§ We are the ONLY Education delivery partners for Mulesoft, Elastic, Pivotal & Lightbend in India ļ‚§ We have delivered more than 5000 trainings and have over 400 courses and a vast pool of over 200 experts to make YOU the EXPERT! FOLLOW US ON SOCIAL MEDIA TO STAY UPDATED ON THE UPCOMING WEBINARS
  • 3. Online and Classroom Training on Technology Courses at SpringPeople Non-Certified Courses …and many more Certified Partners
  • 4. What is MongoDB  MongoDB is an open-source document database and leading NoSQL database  Schema less  Stores JSON objects  document oriented database that provides  high performance  high availability  easy scalability 7/28/2016Pawan Tiwari
  • 5. Why MongoDB  Document Oriented Storage: Data is stored in the form of JSON style documents.  Index on any attribute  Geo Location support  Replication and high availability  Auto-sharding  Rich queries  Fast in-place updates  Professional support by MongoDB 7/28/2016Pawan Tiwari
  • 6. MongoDB Overview  Database  Physical Container of Collection  Collections  Collection is a group of MongoDB documents  equivalent of an RDBMS table  Collections do not enforce a schema.  Document  set of key-value pairs.  Documents have dynamic schema 7/28/2016Pawan Tiwari
  • 7. RDBMS and MongoDB  Database  Database  Table  Collection  Row  Document  Column  Field 7/28/2016Pawan Tiwari
  • 8. Sample Document { _id: ObjectId(7df78ad8902c) a: ā€˜1’, b: ā€˜2’ } 7/28/2016Pawan Tiwari
  • 9. Advantages of MongoDB  Schema less  Structure of a single object is clear.  No complex joins.  Supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL.  Tuning.  Ease of scale-out: MongoDB is easy to scale.  Conversion/mapping of application objects to database objects not needed.  Uses internal memory for storing the (windowed) working set, enabling faster access of data 7/28/2016Pawan Tiwari
  • 10. Create Collection  Db.createcollection(ā€œcollection_nameā€ Options)  Example: MongoDB shell version: 2.4.14 connecting to: test > show dbs local 0.078125GB test 0.203125GB > use test switched to db test > db.createCollection("test_collection") { "ok" : 1 } > 7/28/2016Pawan Tiwari
  • 11. Drop Collection  db.COLLECTION_NAME.drop() MongoDB shell version: 2.4.14 connecting to: test > show collections system.indexes test_collection > db.test_collection.drop() true 7/28/2016Pawan Tiwari
  • 12. Insert Document  db.COLLECTION_NAME.insert(document) >db.test_collection.insert({ title: 'MongoDB Webinar', description: 'MongoDB is a high-performance, open source, schema- free, document/object-oriented database optimized for web application environments, and is perhaps one of the most disruptive software technologies in years. MongoDB will fundamentally change the way participants think about data persistence. In this webinar know the fundamentals of designing and building applications using MongoDB', by: 'SpringPeople', url: 'http://www.springpeople.com/webinars/mongodb-developer-fundamentals-and- basics', }) 7/28/2016Pawan Tiwari
  • 13. Query Document  db.COLLECTION_NAME.find(document) Example: >db.test_collection.find() >db.test_collection.find().pretty() >db.test_collection.find({"title" : "MongoDB Webinar"}) > db.test_collection.find({"title" : "MongoDB Webinar"},{"by":1}).pretty() { "_id" : ObjectId("5791d58760a74da5b3e51eb9"), "by" : "SpringPeople" } > db.test_collection.find({"title" : "MongoDB Webinar"},{"by":1,_id:0}).pretty() { "by" : "SpringPeople" } 7/28/2016Pawan Tiwari
  • 14. SQL vs Mongodb SQL SELECT Statements MongoDB find() Statements SELECT * FROM users db.users.find() SELECT id, user_id, status FROM users db.users.find( { }, { user_id: 1, status: 1 } ) SELECT user_id, status FROM users db.users.find( { }, { user_id: 1, status: 1, _id: 0 } ) SELECT * FROM users WHERE status = "A" db.users.find( { status: "A" } ) SELECT user_id, status FROM users WHERE status = "A" db.users.find( { status: "A" }, { user_id: 1, status: 1, _id: 0 } ) SELECT * FROM users WHERE status != "A" db.users.find( { status: { $ne: "A" } } ) SELECT * FROM users WHERE status = "A" AND age = 50 db.users.find( { status: "A", age: 50 } ) SELECT * FROM users WHERE status = "A" OR age = 50 db.users.find( { $or: [ { status: "A" } , { age: 50 } ] } ) SELECT * FROM users WHERE age > 25 db.users.find( { age: { $gt: 25 } } ) 7/28/2016Pawan Tiwari
  • 15. SQL vs Mongodb 7/28/2016Pawan Tiwari SELECT * FROM users WHERE age < 25 db.users.find( { age: { $lt: 25 } } ) SELECT * FROM users WHERE age > 25 AND age <= 50 db.users.find( { age: { $gt: 25, $lte: 50 } } ) SELECT * FROM users WHERE user_id like "%bc%" db.users.find( { user_id: /bc/ } ) SELECT * FROM users WHERE user_id like "bc%" db.users.find( { user_id: /^bc/ } ) SELECT * FROM users WHERE status = "A" ORDER BY user_id ASC db.users.find( { status: "A" } ).sort( { user_id: 1 } ) SELECT * FROM users WHERE status = "A" ORDER BY user_id DESC db.users.find( { status: "A" } ).sort( { user_id: -1 } ) SELECT COUNT(*) FROM users db.users.count() or db.users.find().count() SELECT COUNT(user_id) FROM users db.users.count( { user_id: { $exists: true } } ) or db.users.find( { user_id: { $exists: true } } ).count()
  • 16. Usefull MongoDB commands 7/28/2016Pawan Tiwari  Db.createcollection(users)  Db.users.insert({ā€œnameā€: ā€œXYZā€})  db.users.createIndex( { user_id: 1 } )  db.users.update( { age: { $gt: 25 } }, { $set: { status: "C" } }, { multi: true } )  db.users.remove( { status: "D" } ) db.users.remove( { status:"D" } )
  • 18. [email protected] Upcoming Mongo DB Classes at SpringPeople Classroom (Bengaluru) 16 - 18 Sept Online LIVE 08 - 17 Aug