SlideShare a Scribd company logo
MongoDB
{Paulo Fagundes}
Introduction
MongoDB is a document database that provides high performance, high availability, and easy
scalability.
•Document Database:
oA record in MongoDB is a document, which is a data structure composed of field and value
pairs
osimilar to JSON objects
Introduction
•High Performance
oEmbedding makes reads and writes fast.
oIndexes can include keys from embedded documents and arrays.
oOptional streaming writes (no acknowledgments).
•High Availability
oReplicated servers with automatic master failover.
•Easy Scalability
oAutomatic sharding distributes collection data across machines.
oEventually-consistent reads can be distributed over replicated servers.
Terminology
•Database:
oA physical container for collection.
oEach database gets its own set of files on the file system.
oA single MongoDB server typically has multiple databases.
•Collection:
oA grouping of MongoDB documents.
oA collection is the equivalent of an RDBMS table.
oA collection exists within a single database.
oCollections do not enforce a schema.
oDocuments within a collection can have different fields.
•Document:
oA record in a MongoDB collection and the basic unit of data in MongoDB.
oDocument is the equivalent of an RDBMS row.
oDocuments are analogous to JSON objects but exist in the database in a more type-rich format
known as BSON.
Terminology
•Field:
oA name-value pair in a document.
oA document has zero or more fields.
oFields are analogous to columns in relational databases.
•Embedded documents and linking:
oTable Join
•Primary Key:
oA record’s unique immutable identifier.
oIn an RDBMS, the primary key is typically an integer stored in each row’s id field.
oIn MongoDB, the _id field holds a document’s primary key which is usually a BSON ObjectId.
Data Types
•null
oNull can be used to represent both a null value and nonexistent field.
o{“x”: null}
•boolean
oused for the values ‘true’ and ‘false’.
o{“x”: true}
•64-bit integer
•64-bit floating point number
o{“x” : 3.14}
•string
o{“x” : “string”}
•object id
ounique 12-byte ID for documents
o{“x”:ObjectId()}
Data Types
•date
oDate are stored in milliseconds since the epoch. The time zone is not stored.
o{“x”:new Date()}
•code
oDocument can also contain JavaScript code
o{“x”: function() {/*.......*/}}
•binary data
•undefined
o{“x”: undefined}
•array
o{“x”: [“a”, “b”, “c”]}
•embedded document
oDocument can contain entire documents, embedded as values in the parent document.
o{“x”: {“name” : “Your Name”}}
MongoDB Commands
•Start MongoDB
omongo
•List All Database
oshow databases;
•Create and use Database
ouse databas_name;
•Check current database selected
odb
•Create New collection
odb.createCollection(collectionName);
•Show All collections
oshow collections
•Drop Database
odb.dropDatabase();
•Drop Collection
odb.collection_name.drop();
MongoDB Query
•Insert Document
>db.collection_name.insert(document)
•Example;
>db.mycol.insert({
_id: ObjectId(7df78ad8902c),
title: 'MongoDB Overview',
description: 'MongoDB is no sql database',
by: ganesh kunwar,
url: 'http://www.ganeshkunwar.com.np',
tags: ['mongodb', 'database', 'NoSQL'],
likes: 100
})
MongoDB Query
•Find()
oquery data from collection
o> db.COLLECTION_NAME.find()
{ "_id" : ObjectId("53371ed996322bd29e878e2b"), "title" : "MongoDB Overview",
"description" : "MongoDB is no sql database", "by" : "ganesh kunwar", "url" :
"http://www.ganeshkunwar.com.np", "tags" : [ "mongodb", "database", "NoSQL" ], "likes" : 100 }
•Pretty()
odisplay the result in formatted way
o> db.COLLECTION_NAME.find().pretty()
{
_id: ObjectId(7df78ad8902c),
title: 'MongoDB Overview',
description: 'MongoDB is no sql database',
by: ganesh kunwar,
url: 'http://www.ganeshkunwar.com.np',
tags: ['mongodb', 'database', 'NoSQL'],
likes: 100
}
MongoDB Query
•findOne()
oreturns only one document.
•And in MongoDB
o> db.mycol.find(key1: value1, key2: value2)
•OR in MongoDB
o> db.mycol.find($or: [{key1: value1}, {key2, value2}] )
•And and OR together
o> db.myclo.find(key1: val1, $or: [{key2: value2}, {key3, value3}] )
RDBMS Where Clause Equivalents in MongoDB
Operati
on
Syntax Example RDBMS Equivalent
Equalit
y
{<key>:
<value>
}
db.mycol.find({"by
":"ganesh
kunwar"}).pretty()
where by = 'ganesh kunwart'
Less
Than
{<key>:{
$lt:<valu
e>}}
db.mycol.find({"lik
es":{$lt:50}}).pretty
()
where likes < 50
Less
Than
Equals
{<key>:{
$lte:<val
ue>}}
db.mycol.find({"lik
es":{$lte:50}}).pret
ty()
where likes <= 50
Greate
r Than
{<key>:{
$gt:<val
ue>}}
db.mycol.find({"lik
es":{$gt:50}}).prett
y()
where likes > 50
Greate
r Than
Equals
{<key>:{
$gte:<v
alue>}}
db.mycol.find({"lik
es":{$gte:50}}).pre
tty()
where likes >= 50
Not
Equals
{<key>:{
$ne:<va
lue>}}
db.mycol.find({"lik
es":{$ne:50}}).pret
ty()
where likes != 50
Update
•Syntax:
o>db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA)
•Example
o{ "_id" : ObjectId(5983548781331adf45ec5), "title":"MongoDB Overview"}
o>db.mycol.update({'title':'MongoDB Overview'}, {$set:{'title':'New MongoDB Tutorial'}})
o{ "_id" : ObjectId(5983548781331adf45ec5), "title":"New MongoDB Tutorial"}
Delete
•The remove() method
o>db.COLLECTION_NAME.remove(DELLETION_CRITTERIA)
•Remove only one
o>db.COLLECTION_NAME.remove(DELETION_CRITERIA,1)
•Remove All documents
o>db.mycol.remove()
Projection
•selecting only necessary data rather than selecting whole of the data of a document
•Syntax
o>db.COLLECTION_NAME.find({},{KEY:1})
•Example
o>db.mycol.find({},{"title":1})
Limiting Records
•The Limit() Method
oSyntax
o>db.COLLECTION_NAME.find().limit(NUMBER)
oExample
o>db.mycol.find({},{"title":1,_id:0}).limit(2)
•MongoDB Skip() Method
oaccepts number type argument and used to skip number of documents.
oSyntax
o>db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)
oExample
o>db.mycol.find({},{"title":1,_id:0}).limit(1).skip(1)
Sorting Records
•Ascending order
o>db.COLLECTION_NAME.find().sort({KEY:1})
•Descending order
o>db.COLLECTION_NAME.find().sort({KEY:-1})
MongoDB Backup
•Backup Options
oMongodump
oCopy files
oSnapshot disk
•Mongodump
omongodump --db mongodevdb --username mongodevdb --password YourSecretPwd
oDumps collections to *.bson files
oMirrors your structure
oCan be run in live or offline mode
•Mongorestore
omongorestore --dbpath /var/lib/mongo --db mongodevdb dump/mongodevdb
Questions
?
Thank You

More Related Content

What's hot

Mongo db
Mongo dbMongo db
Mongo db
Raghu nath
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
MongoDB
 
MongoDB
MongoDBMongoDB
2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB
antoinegirbal
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
MongoDB
 
MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
TO THE NEW | Technology
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentationMurat Çakal
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
Mike Friedman
 
Tag based sharding presentation
Tag based sharding presentationTag based sharding presentation
Tag based sharding presentation
Juan Antonio Roy Couto
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
Abhijeet Vaikar
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
MongoDB Basics Unileon
MongoDB Basics UnileonMongoDB Basics Unileon
MongoDB Basics Unileon
Juan Antonio Roy Couto
 
MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive GuideWildan Maulana
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
joergreichert
 
MongoDB - javascript for your data
MongoDB - javascript for your dataMongoDB - javascript for your data
MongoDB - javascript for your data
aaronheckmann
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
MongoDB
 
MongoDB Concepts
MongoDB ConceptsMongoDB Concepts
MongoDB Concepts
Juan Antonio Roy Couto
 

What's hot (18)

Mongo db
Mongo dbMongo db
Mongo db
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
MongoDB
MongoDBMongoDB
MongoDB
 
2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB2011 Mongo FR - Indexing in MongoDB
2011 Mongo FR - Indexing in MongoDB
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
 Back to Basics Webinar 3: Schema Design Thinking in Documents Back to Basics Webinar 3: Schema Design Thinking in Documents
Back to Basics Webinar 3: Schema Design Thinking in Documents
 
MongoDb and NoSQL
MongoDb and NoSQLMongoDb and NoSQL
MongoDb and NoSQL
 
Building web applications with mongo db presentation
Building web applications with mongo db presentationBuilding web applications with mongo db presentation
Building web applications with mongo db presentation
 
Webinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in DocumentsWebinar: Back to Basics: Thinking in Documents
Webinar: Back to Basics: Thinking in Documents
 
MongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World ExamplesMongoDB Schema Design: Four Real-World Examples
MongoDB Schema Design: Four Real-World Examples
 
Tag based sharding presentation
Tag based sharding presentationTag based sharding presentation
Tag based sharding presentation
 
MongoDB 101
MongoDB 101MongoDB 101
MongoDB 101
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
 
MongoDB Basics Unileon
MongoDB Basics UnileonMongoDB Basics Unileon
MongoDB Basics Unileon
 
MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive Guide
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
MongoDB - javascript for your data
MongoDB - javascript for your dataMongoDB - javascript for your data
MongoDB - javascript for your data
 
Indexing Strategies to Help You Scale
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
 
MongoDB Concepts
MongoDB ConceptsMongoDB Concepts
MongoDB Concepts
 

Similar to Mondodb

MongoDB
MongoDBMongoDB
MongoDB
Ganesh Kunwar
 
Mongo DB
Mongo DB Mongo DB
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
1AP18CS037ShirishKul
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
Habilelabs
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
Antonio Pintus
 
Mongo db
Mongo dbMongo db
Mongo db
Gyanendra Yadav
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behl
TO THE NEW | Technology
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
Norberto Leite
 
3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
S.Shayan Daneshvar
 
Mongo db tutorials
Mongo db tutorialsMongo db tutorials
Mongo db tutorials
Anuj Jain
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup
WebGeek Philippines
 
Mongodb Introduction
Mongodb IntroductionMongodb Introduction
Mongodb Introduction
Raghvendra Parashar
 
MongoDB
MongoDBMongoDB
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
jeetendra mandal
 
UNIT-1 MongoDB.pptx
UNIT-1 MongoDB.pptxUNIT-1 MongoDB.pptx
UNIT-1 MongoDB.pptx
DharaDarji5
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesignMongoDB APAC
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Hossein Boustani
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Sean Laurent
 

Similar to Mondodb (20)

MongoDB
MongoDBMongoDB
MongoDB
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behl
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
lecture_34e.pptx
lecture_34e.pptxlecture_34e.pptx
lecture_34e.pptx
 
Mongo db tutorials
Mongo db tutorialsMongo db tutorials
Mongo db tutorials
 
10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup10gen MongoDB Video Presentation at WebGeek DevCup
10gen MongoDB Video Presentation at WebGeek DevCup
 
Mongodb Introduction
Mongodb IntroductionMongodb Introduction
Mongodb Introduction
 
MongoDB
MongoDBMongoDB
MongoDB
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
UNIT-1 MongoDB.pptx
UNIT-1 MongoDB.pptxUNIT-1 MongoDB.pptx
UNIT-1 MongoDB.pptx
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 

More from Paulo Fagundes

Oracle exalytics deployment for high availability
Oracle exalytics deployment for high availabilityOracle exalytics deployment for high availability
Oracle exalytics deployment for high availability
Paulo Fagundes
 
Backup and Restore of database on 2-Node RAC
Backup and Restore of database on 2-Node RACBackup and Restore of database on 2-Node RAC
Backup and Restore of database on 2-Node RAC
Paulo Fagundes
 
Zero Downtime for Oracle E-Business Suite on Oracle Exalogic
Zero Downtime for Oracle E-Business Suite on Oracle ExalogicZero Downtime for Oracle E-Business Suite on Oracle Exalogic
Zero Downtime for Oracle E-Business Suite on Oracle Exalogic
Paulo Fagundes
 
Mongodb
MongodbMongodb
MongoDB for the SQL Server
MongoDB for the SQL ServerMongoDB for the SQL Server
MongoDB for the SQL Server
Paulo Fagundes
 
MongoDB - Javascript for your Data
MongoDB - Javascript for your DataMongoDB - Javascript for your Data
MongoDB - Javascript for your DataPaulo Fagundes
 
The Little MongoDB Book - Karl Seguin
The Little MongoDB Book - Karl SeguinThe Little MongoDB Book - Karl Seguin
The Little MongoDB Book - Karl Seguin
Paulo Fagundes
 
Oracle NoSQL Database Compared to Cassandra and HBase
Oracle NoSQL Database Compared to Cassandra and HBaseOracle NoSQL Database Compared to Cassandra and HBase
Oracle NoSQL Database Compared to Cassandra and HBase
Paulo Fagundes
 
The Power of Relationships in Your Big Data
The Power of Relationships in Your Big DataThe Power of Relationships in Your Big Data
The Power of Relationships in Your Big DataPaulo Fagundes
 
Oracle NoSQL Database release 3.0 overview
Oracle NoSQL Database release 3.0 overviewOracle NoSQL Database release 3.0 overview
Oracle NoSQL Database release 3.0 overviewPaulo Fagundes
 

More from Paulo Fagundes (11)

Oracle exalytics deployment for high availability
Oracle exalytics deployment for high availabilityOracle exalytics deployment for high availability
Oracle exalytics deployment for high availability
 
Backup and Restore of database on 2-Node RAC
Backup and Restore of database on 2-Node RACBackup and Restore of database on 2-Node RAC
Backup and Restore of database on 2-Node RAC
 
Zero Downtime for Oracle E-Business Suite on Oracle Exalogic
Zero Downtime for Oracle E-Business Suite on Oracle ExalogicZero Downtime for Oracle E-Business Suite on Oracle Exalogic
Zero Downtime for Oracle E-Business Suite on Oracle Exalogic
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB for the SQL Server
MongoDB for the SQL ServerMongoDB for the SQL Server
MongoDB for the SQL Server
 
MongoDB - Javascript for your Data
MongoDB - Javascript for your DataMongoDB - Javascript for your Data
MongoDB - Javascript for your Data
 
Capacityplanning
Capacityplanning Capacityplanning
Capacityplanning
 
The Little MongoDB Book - Karl Seguin
The Little MongoDB Book - Karl SeguinThe Little MongoDB Book - Karl Seguin
The Little MongoDB Book - Karl Seguin
 
Oracle NoSQL Database Compared to Cassandra and HBase
Oracle NoSQL Database Compared to Cassandra and HBaseOracle NoSQL Database Compared to Cassandra and HBase
Oracle NoSQL Database Compared to Cassandra and HBase
 
The Power of Relationships in Your Big Data
The Power of Relationships in Your Big DataThe Power of Relationships in Your Big Data
The Power of Relationships in Your Big Data
 
Oracle NoSQL Database release 3.0 overview
Oracle NoSQL Database release 3.0 overviewOracle NoSQL Database release 3.0 overview
Oracle NoSQL Database release 3.0 overview
 

Recently uploaded

一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 

Recently uploaded (20)

一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 

Mondodb

  • 2. Introduction MongoDB is a document database that provides high performance, high availability, and easy scalability. •Document Database: oA record in MongoDB is a document, which is a data structure composed of field and value pairs osimilar to JSON objects
  • 3. Introduction •High Performance oEmbedding makes reads and writes fast. oIndexes can include keys from embedded documents and arrays. oOptional streaming writes (no acknowledgments). •High Availability oReplicated servers with automatic master failover. •Easy Scalability oAutomatic sharding distributes collection data across machines. oEventually-consistent reads can be distributed over replicated servers.
  • 4. Terminology •Database: oA physical container for collection. oEach database gets its own set of files on the file system. oA single MongoDB server typically has multiple databases. •Collection: oA grouping of MongoDB documents. oA collection is the equivalent of an RDBMS table. oA collection exists within a single database. oCollections do not enforce a schema. oDocuments within a collection can have different fields. •Document: oA record in a MongoDB collection and the basic unit of data in MongoDB. oDocument is the equivalent of an RDBMS row. oDocuments are analogous to JSON objects but exist in the database in a more type-rich format known as BSON.
  • 5. Terminology •Field: oA name-value pair in a document. oA document has zero or more fields. oFields are analogous to columns in relational databases. •Embedded documents and linking: oTable Join •Primary Key: oA record’s unique immutable identifier. oIn an RDBMS, the primary key is typically an integer stored in each row’s id field. oIn MongoDB, the _id field holds a document’s primary key which is usually a BSON ObjectId.
  • 6. Data Types •null oNull can be used to represent both a null value and nonexistent field. o{“x”: null} •boolean oused for the values ‘true’ and ‘false’. o{“x”: true} •64-bit integer •64-bit floating point number o{“x” : 3.14} •string o{“x” : “string”} •object id ounique 12-byte ID for documents o{“x”:ObjectId()}
  • 7. Data Types •date oDate are stored in milliseconds since the epoch. The time zone is not stored. o{“x”:new Date()} •code oDocument can also contain JavaScript code o{“x”: function() {/*.......*/}} •binary data •undefined o{“x”: undefined} •array o{“x”: [“a”, “b”, “c”]} •embedded document oDocument can contain entire documents, embedded as values in the parent document. o{“x”: {“name” : “Your Name”}}
  • 8. MongoDB Commands •Start MongoDB omongo •List All Database oshow databases; •Create and use Database ouse databas_name; •Check current database selected odb •Create New collection odb.createCollection(collectionName); •Show All collections oshow collections •Drop Database odb.dropDatabase(); •Drop Collection odb.collection_name.drop();
  • 9. MongoDB Query •Insert Document >db.collection_name.insert(document) •Example; >db.mycol.insert({ _id: ObjectId(7df78ad8902c), title: 'MongoDB Overview', description: 'MongoDB is no sql database', by: ganesh kunwar, url: 'http://www.ganeshkunwar.com.np', tags: ['mongodb', 'database', 'NoSQL'], likes: 100 })
  • 10. MongoDB Query •Find() oquery data from collection o> db.COLLECTION_NAME.find() { "_id" : ObjectId("53371ed996322bd29e878e2b"), "title" : "MongoDB Overview", "description" : "MongoDB is no sql database", "by" : "ganesh kunwar", "url" : "http://www.ganeshkunwar.com.np", "tags" : [ "mongodb", "database", "NoSQL" ], "likes" : 100 } •Pretty() odisplay the result in formatted way o> db.COLLECTION_NAME.find().pretty() { _id: ObjectId(7df78ad8902c), title: 'MongoDB Overview', description: 'MongoDB is no sql database', by: ganesh kunwar, url: 'http://www.ganeshkunwar.com.np', tags: ['mongodb', 'database', 'NoSQL'], likes: 100 }
  • 11. MongoDB Query •findOne() oreturns only one document. •And in MongoDB o> db.mycol.find(key1: value1, key2: value2) •OR in MongoDB o> db.mycol.find($or: [{key1: value1}, {key2, value2}] ) •And and OR together o> db.myclo.find(key1: val1, $or: [{key2: value2}, {key3, value3}] )
  • 12. RDBMS Where Clause Equivalents in MongoDB Operati on Syntax Example RDBMS Equivalent Equalit y {<key>: <value> } db.mycol.find({"by ":"ganesh kunwar"}).pretty() where by = 'ganesh kunwart' Less Than {<key>:{ $lt:<valu e>}} db.mycol.find({"lik es":{$lt:50}}).pretty () where likes < 50 Less Than Equals {<key>:{ $lte:<val ue>}} db.mycol.find({"lik es":{$lte:50}}).pret ty() where likes <= 50 Greate r Than {<key>:{ $gt:<val ue>}} db.mycol.find({"lik es":{$gt:50}}).prett y() where likes > 50 Greate r Than Equals {<key>:{ $gte:<v alue>}} db.mycol.find({"lik es":{$gte:50}}).pre tty() where likes >= 50 Not Equals {<key>:{ $ne:<va lue>}} db.mycol.find({"lik es":{$ne:50}}).pret ty() where likes != 50
  • 13. Update •Syntax: o>db.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA) •Example o{ "_id" : ObjectId(5983548781331adf45ec5), "title":"MongoDB Overview"} o>db.mycol.update({'title':'MongoDB Overview'}, {$set:{'title':'New MongoDB Tutorial'}}) o{ "_id" : ObjectId(5983548781331adf45ec5), "title":"New MongoDB Tutorial"}
  • 14. Delete •The remove() method o>db.COLLECTION_NAME.remove(DELLETION_CRITTERIA) •Remove only one o>db.COLLECTION_NAME.remove(DELETION_CRITERIA,1) •Remove All documents o>db.mycol.remove()
  • 15. Projection •selecting only necessary data rather than selecting whole of the data of a document •Syntax o>db.COLLECTION_NAME.find({},{KEY:1}) •Example o>db.mycol.find({},{"title":1})
  • 16. Limiting Records •The Limit() Method oSyntax o>db.COLLECTION_NAME.find().limit(NUMBER) oExample o>db.mycol.find({},{"title":1,_id:0}).limit(2) •MongoDB Skip() Method oaccepts number type argument and used to skip number of documents. oSyntax o>db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER) oExample o>db.mycol.find({},{"title":1,_id:0}).limit(1).skip(1)
  • 18. MongoDB Backup •Backup Options oMongodump oCopy files oSnapshot disk •Mongodump omongodump --db mongodevdb --username mongodevdb --password YourSecretPwd oDumps collections to *.bson files oMirrors your structure oCan be run in live or offline mode •Mongorestore omongorestore --dbpath /var/lib/mongo --db mongodevdb dump/mongodevdb