SlideShare a Scribd company logo
INTRODUCTION TO MONGODB
BY : MRS SANGEETA M CHAUHAN
PGT COMPUTER SCIENCE
KV NO.3 MORAR CANTT GWALIOR
1.Introduction MongoDB
2.To know about terminologies used in MongoDB
3.To Know about basic commands of Mongo DB
4.To Relate MongoDB with SQL Queries
PREREQUISITE
1.Database and its
Structure
2.Concept of Queries
3.Schema
MongoDB is an open source database that uses a document-
oriented data model.
MongoDB is one of several database types to arise in the
mid-2000s under the NoSQLbanner. Instead of using tables
and rows as in relational databases, MongoDB is built on an
architecture of collections and documents.
INTRODUCTION
Documents comprise sets of key-value pairs
and are the basic unit of data in MongoDB.
Collections contain sets of documents and
function as the equivalent of relational
database tables.
CONTINUED….
ABOUT MongoDB
• Developed by 10gen
• Founded in 2007
•Written in C++
FEATURES OF MongoDB ...
FREE
1
2
3
22
RDBMS MongoDB
Database Database
Table, View Collection
Row Document (BSON)
Column Field
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
Collection is
not strict
about what it
Stores
Schema-less
Hierarchy is
evident in the
design
Embe
dded
Docum
ent ?
vs
DOCUMENT
A document in MongoDB is like a JSON.
Example:
{'name': 'Christiano',
'language': 'Python',
'country': 'Brazil'}
MongoDB is a document-oriented database. Instead of storing your
data in tables made out of individual rows, like a relational database
does, it stores your data in collections made out of
individual documents.
In MongoDB, a document is a big JSON blob with no particular format
or schema.N
YOU CAN DYNAMICALLY
UPDATE YOUR DATA
, example:
{'name': 'Christiano',
'language': 'Python',
'country': 'Brazil'}
{'name': 'Christiano',
'language': 'Python',
'country': 'Brazil',
'event': 'PyConAr'}
In MongoDB, databases hold collections
of documents.
use <db> statement,
use myDB
Databases
CREATION OF DATABASE
 If a database does not exist, MongoDB creates the
database when you first store data for that database.
• MongoDB does not need any pre-defined data schema
• Every document in a collection could have different data
• Addresses NULL data fields
SCHEMA FREE
name: “jeff”,
eyes: “blue”, loc:
[40.7, 73.4],
boss: “ben”}
{name: “brendan”,
aliases: [“el diablo”]}
name: “ben”,
hat: ”yes”}
{name: “matt”,
pizza: “DiGiorno”,
height: 72,
loc: [44.6, 71.3]}
{name:
“will”,
eyes:
“blue”,
birthplace:
“NY”,
aliases:
[“bill”, “la
ciacco”],
loc: [32.7,
63.4],
boss:
”ben”}
• Data is in name / value pairs
• A name/value pair consists of a field name
followed by a colon, followed by a value:
• Example: “name”: “R2-D2”
• Data is separated by commas
• Example: “name”: “R2-D2”, race : “Droid”
• Curly braces hold objects
• Example: {“name”: “R2-D2”, race : “Droid”, affiliation:
“rebels”}
• An array is stored in brackets []
• Example [ {“name”: “R2-D2”, race : “Droid”,
affiliation: “rebels”},
• {“name”: “Yoda”, affiliation: “rebels”} ]
JSON FORMAT
INSERTION OF DOCUMENTS
db.inventory.insertOne
({ item: "canvas", qty: 100,tags: ["cotton"], size:
{h: 28, w: 35.5, unit: "cm" } } )
Inserting Single Documents
EXAMPLE : INSERT MULTIPLE DOCUMENTS
db.inventory.insertMany
([{ item: “Freeze“,qty: 25, tags: ["blank", "red"],size:{ h: 14, w: 21, unit: "cm" }},
{ item: “TV“,qty: 85, tags: ["gray"],size:{ h: 27.9, w: 35.5, unit : "cm" } },
{ item: “AC“,qty:25,tags: [“white”], "blue"],size:{ h: 19, w: 22.85, unit:"cm" } }
])
Inserting Multiple Documents
db.collection.insertMany():
can insert multiple documents into a collection.
Pass an array of documents to the method.
Query Operators
Name Description
$eq Matches value that are equal to a specified value
$gt, $gte Matches values that are greater than (or equal to a specified value
$lt, $lte Matches values less than or ( equal to ) a specified value
$ne Matches values that are not equal to a specified value
$in Matches any of the values specified in an array
$nin Matches none of the values specified in an array
$or Joins query clauses with a logical OR returns all
$and Join query clauses with a loginal AND
$not Inverts the effect of a query expression
$nor Join query clauses with a logical NOR
$exists Matches documents that have a specified field
 MongoDB sample Commands:

 Ques. Show all databases:
 show dbs

Ques. Create a Database Named ‘workshop’:
 use workshop

 Ques. Creating a collection/table named ‘student’ in ‘workshop’ database:
 db.createCollection(“student”)

 Ques. Inserting a document/record in ‘student’:
 db.student.insertOne({RollNo:1, Name:"Aashna", Marks:80})

 Ques. Inserting multiple documents/records in ‘student’:
 db.student.insertMany( [{RollNo:2, Name:"Abhinav", Marks:70},
 {RollNo:3, Name:"Ayesha", Marks:85},
 {RollNo:4, Name:"Mohit", Marks:72} ] )

 Ques. Display all records/documents from ‘student’:
 db.student.find()

 Ques. Display details of students having Marks more than 80:
 db.student.find( { Marks : { $gt : 80} } )
mongodb crud operations with detailed.ppt
Lets Relate the
MongoDB Queries
with SQL
db.users.insert({a:1,b:2})
 Insert into Users Values(1,2)
db.users.find( )
 Select * from users;
db.users.find({age:33})
 Select * from users where age=33
 db.users.find({‘name’:‘Manasvi’,Age:12})
 Select * From Users where name=‘Manasvi’ and
Age=12;
db.users.find({‘a:{$gt:22}})
 Select * from users where a>22;
db.users.sort({name:-1})
 Select * from users order by name desc;
WHAT IS JSON?
JSON is acronym of Java Object
Notation which is a format for
structuring data to transmit data
between server and web application
Q1. Write a query in MongoDB to Search records of Clerk Employee
Q2. Write a query in MongoDB to print records of all Students
Q3. What do you mean by Schema?
mongodb crud operations with detailed.ppt

More Related Content

Similar to mongodb crud operations with detailed.ppt (20)

PPTX
mongodb introduction11111111111111111111
VADAPALLYPRAVEENKUMA1
 
PPTX
Mondodb
Paulo Fagundes
 
PPTX
MongoDB using Grails plugin by puneet behl
TO THE NEW | Technology
 
PPTX
Mongo db
Raghu nath
 
PDF
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
PPTX
MongoDB - An Introduction
dinkar thakur
 
PPTX
MongoDB
Ganesh Kunwar
 
PPTX
Mongo db
Ramakrishna kapa
 
PPTX
lecture_34e.pptx
janibashashaik25
 
KEY
London MongoDB User Group April 2011
Rainforest QA
 
PPTX
Mongo DB Presentation
Jaya Naresh Kovela
 
PPTX
MongoDB-presentation.pptx
tarungupta276841
 
PDF
MongoDB Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
Mongo learning series
Prashanth Panduranga
 
PPTX
Introduction to MongoDB.pptx
Surya937648
 
PPTX
UNIT-1 MongoDB.pptx
DharaDarji5
 
PDF
MongoDB
wiTTyMinds1
 
PPTX
Mongodb Introduction
Nabeel Naqeebi
 
PPTX
29thMarchMongodb and its history features.pptx
ajajkhan16
 
PPTX
Kalp Corporate MongoDB Tutorials
Kalp Corporate
 
mongodb introduction11111111111111111111
VADAPALLYPRAVEENKUMA1
 
MongoDB using Grails plugin by puneet behl
TO THE NEW | Technology
 
Mongo db
Raghu nath
 
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
MongoDB - An Introduction
dinkar thakur
 
MongoDB
Ganesh Kunwar
 
lecture_34e.pptx
janibashashaik25
 
London MongoDB User Group April 2011
Rainforest QA
 
Mongo DB Presentation
Jaya Naresh Kovela
 
MongoDB-presentation.pptx
tarungupta276841
 
MongoDB Interview Questions PDF By ScholarHat
Scholarhat
 
Mongo learning series
Prashanth Panduranga
 
Introduction to MongoDB.pptx
Surya937648
 
UNIT-1 MongoDB.pptx
DharaDarji5
 
MongoDB
wiTTyMinds1
 
Mongodb Introduction
Nabeel Naqeebi
 
29thMarchMongodb and its history features.pptx
ajajkhan16
 
Kalp Corporate MongoDB Tutorials
Kalp Corporate
 

Recently uploaded (20)

PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Horarios de distribución de agua en julio
pegazohn1978
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Introduction presentation of the patentbutler tool
MIPLM
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
epi editorial commitee meeting presentation
MIPLM
 
Is Assignment Help Legal in Australia_.pdf
thomas19williams83
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Controller Request and Response in Odoo18
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
Ad

mongodb crud operations with detailed.ppt

  • 1. INTRODUCTION TO MONGODB BY : MRS SANGEETA M CHAUHAN PGT COMPUTER SCIENCE KV NO.3 MORAR CANTT GWALIOR
  • 2. 1.Introduction MongoDB 2.To know about terminologies used in MongoDB 3.To Know about basic commands of Mongo DB 4.To Relate MongoDB with SQL Queries
  • 4. MongoDB is an open source database that uses a document- oriented data model. MongoDB is one of several database types to arise in the mid-2000s under the NoSQLbanner. Instead of using tables and rows as in relational databases, MongoDB is built on an architecture of collections and documents. INTRODUCTION
  • 5. Documents comprise sets of key-value pairs and are the basic unit of data in MongoDB. Collections contain sets of documents and function as the equivalent of relational database tables. CONTINUED….
  • 6. ABOUT MongoDB • Developed by 10gen • Founded in 2007 •Written in C++
  • 7. FEATURES OF MongoDB ... FREE 1 2 3
  • 8. 22 RDBMS MongoDB Database Database Table, View Collection Row Document (BSON) Column Field Index Index Join Embedded Document Foreign Key Reference Partition Shard Collection is not strict about what it Stores Schema-less Hierarchy is evident in the design Embe dded Docum ent ? vs
  • 9. DOCUMENT A document in MongoDB is like a JSON. Example: {'name': 'Christiano', 'language': 'Python', 'country': 'Brazil'} MongoDB is a document-oriented database. Instead of storing your data in tables made out of individual rows, like a relational database does, it stores your data in collections made out of individual documents. In MongoDB, a document is a big JSON blob with no particular format or schema.N
  • 10. YOU CAN DYNAMICALLY UPDATE YOUR DATA , example: {'name': 'Christiano', 'language': 'Python', 'country': 'Brazil'} {'name': 'Christiano', 'language': 'Python', 'country': 'Brazil', 'event': 'PyConAr'}
  • 11. In MongoDB, databases hold collections of documents. use <db> statement, use myDB Databases
  • 12. CREATION OF DATABASE  If a database does not exist, MongoDB creates the database when you first store data for that database.
  • 13. • MongoDB does not need any pre-defined data schema • Every document in a collection could have different data • Addresses NULL data fields SCHEMA FREE name: “jeff”, eyes: “blue”, loc: [40.7, 73.4], boss: “ben”} {name: “brendan”, aliases: [“el diablo”]} name: “ben”, hat: ”yes”} {name: “matt”, pizza: “DiGiorno”, height: 72, loc: [44.6, 71.3]} {name: “will”, eyes: “blue”, birthplace: “NY”, aliases: [“bill”, “la ciacco”], loc: [32.7, 63.4], boss: ”ben”}
  • 14. • Data is in name / value pairs • A name/value pair consists of a field name followed by a colon, followed by a value: • Example: “name”: “R2-D2” • Data is separated by commas • Example: “name”: “R2-D2”, race : “Droid” • Curly braces hold objects • Example: {“name”: “R2-D2”, race : “Droid”, affiliation: “rebels”} • An array is stored in brackets [] • Example [ {“name”: “R2-D2”, race : “Droid”, affiliation: “rebels”}, • {“name”: “Yoda”, affiliation: “rebels”} ] JSON FORMAT
  • 15. INSERTION OF DOCUMENTS db.inventory.insertOne ({ item: "canvas", qty: 100,tags: ["cotton"], size: {h: 28, w: 35.5, unit: "cm" } } ) Inserting Single Documents
  • 16. EXAMPLE : INSERT MULTIPLE DOCUMENTS db.inventory.insertMany ([{ item: “Freeze“,qty: 25, tags: ["blank", "red"],size:{ h: 14, w: 21, unit: "cm" }}, { item: “TV“,qty: 85, tags: ["gray"],size:{ h: 27.9, w: 35.5, unit : "cm" } }, { item: “AC“,qty:25,tags: [“white”], "blue"],size:{ h: 19, w: 22.85, unit:"cm" } } ]) Inserting Multiple Documents db.collection.insertMany(): can insert multiple documents into a collection. Pass an array of documents to the method.
  • 17. Query Operators Name Description $eq Matches value that are equal to a specified value $gt, $gte Matches values that are greater than (or equal to a specified value $lt, $lte Matches values less than or ( equal to ) a specified value $ne Matches values that are not equal to a specified value $in Matches any of the values specified in an array $nin Matches none of the values specified in an array $or Joins query clauses with a logical OR returns all $and Join query clauses with a loginal AND $not Inverts the effect of a query expression $nor Join query clauses with a logical NOR $exists Matches documents that have a specified field
  • 18.  MongoDB sample Commands:   Ques. Show all databases:  show dbs  Ques. Create a Database Named ‘workshop’:  use workshop   Ques. Creating a collection/table named ‘student’ in ‘workshop’ database:  db.createCollection(“student”)   Ques. Inserting a document/record in ‘student’:  db.student.insertOne({RollNo:1, Name:"Aashna", Marks:80})   Ques. Inserting multiple documents/records in ‘student’:  db.student.insertMany( [{RollNo:2, Name:"Abhinav", Marks:70},  {RollNo:3, Name:"Ayesha", Marks:85},  {RollNo:4, Name:"Mohit", Marks:72} ] )   Ques. Display all records/documents from ‘student’:  db.student.find()   Ques. Display details of students having Marks more than 80:  db.student.find( { Marks : { $gt : 80} } )
  • 20. Lets Relate the MongoDB Queries with SQL
  • 23. db.users.find({age:33})  Select * from users where age=33
  • 24.  db.users.find({‘name’:‘Manasvi’,Age:12})  Select * From Users where name=‘Manasvi’ and Age=12;
  • 26. db.users.sort({name:-1})  Select * from users order by name desc;
  • 27. WHAT IS JSON? JSON is acronym of Java Object Notation which is a format for structuring data to transmit data between server and web application
  • 28. Q1. Write a query in MongoDB to Search records of Clerk Employee Q2. Write a query in MongoDB to print records of all Students Q3. What do you mean by Schema?