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

PPT
Mongo db basics
PPTX
Introduction to MongoDB
PDF
Mongo db basics
PPTX
MongoDbPpt based on python installation.
PPTX
Introduction to MongoDB – A NoSQL Database
PPTX
mongo.pptx
PPTX
MongoDB introduction features -presentation - 2.pptx
PDF
MongoDB.pdf54teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeer
Mongo db basics
Introduction to MongoDB
Mongo db basics
MongoDbPpt based on python installation.
Introduction to MongoDB – A NoSQL Database
mongo.pptx
MongoDB introduction features -presentation - 2.pptx
MongoDB.pdf54teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeer

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

PPTX
mongodb introduction11111111111111111111
PPTX
PPTX
MongoDB using Grails plugin by puneet behl
PPTX
Mongo db
PDF
3-Mongodb and Mapreduce Programming.pdf
PPTX
No SQL DB lecture showing structure and syntax
PPTX
MongoDB - An Introduction
PPTX
MongoDB
PPTX
PPTX
lecture_34e.pptx
KEY
London MongoDB User Group April 2011
PPTX
Mongo DB Presentation
PPTX
MongoDB-presentation.pptx
PDF
MongoDB Interview Questions PDF By ScholarHat
PDF
Mongo learning series
PPTX
Introduction to MongoDB.pptx
PPTX
UNIT-1 MongoDB.pptx
PDF
MongoDB
PPTX
Mongodb Introduction
PPTX
29thMarchMongodb and its history features.pptx
mongodb introduction11111111111111111111
MongoDB using Grails plugin by puneet behl
Mongo db
3-Mongodb and Mapreduce Programming.pdf
No SQL DB lecture showing structure and syntax
MongoDB - An Introduction
MongoDB
lecture_34e.pptx
London MongoDB User Group April 2011
Mongo DB Presentation
MongoDB-presentation.pptx
MongoDB Interview Questions PDF By ScholarHat
Mongo learning series
Introduction to MongoDB.pptx
UNIT-1 MongoDB.pptx
MongoDB
Mongodb Introduction
29thMarchMongodb and its history features.pptx
Ad

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
RMMM.pdf make it easy to upload and study
PDF
Complications of Minimal Access Surgery at WLH
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Lesson notes of climatology university.
PPTX
Presentation on HIE in infants and its manifestations
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Pharma ospi slides which help in ospi learning
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Structure & Organelles in detailed.
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
RMMM.pdf make it easy to upload and study
Complications of Minimal Access Surgery at WLH
GDM (1) (1).pptx small presentation for students
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Abdominal Access Techniques with Prof. Dr. R K Mishra
102 student loan defaulters named and shamed – Is someone you know on the list?
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Lesson notes of climatology university.
Presentation on HIE in infants and its manifestations
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Pharma ospi slides which help in ospi learning
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
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?