SlideShare ist ein Scribd-Unternehmen logo
1 von 20
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

Weitere ähnliche Inhalte

Was ist angesagt?

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 presentation
Murat Çakal
 
MongoDB : The Definitive Guide
MongoDB : The Definitive GuideMongoDB : The Definitive Guide
MongoDB : The Definitive Guide
Wildan Maulana
 

Was ist angesagt? (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
 

Ähnlich wie Mondodb

3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
MarianJRuben
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
MongoDB APAC
 

Ähnlich wie 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
 

Mehr von Paulo Fagundes

MongoDB - Javascript for your Data
MongoDB - Javascript for your DataMongoDB - Javascript for your Data
MongoDB - Javascript for your Data
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 Data
Paulo 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 overview
Paulo Fagundes
 

Mehr von 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
 

Kürzlich hochgeladen

怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
vexqp
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
HyderabadDolls
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
HyderabadDolls
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
gajnagarg
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Bertram Ludäscher
 
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
HyderabadDolls
 

Kürzlich hochgeladen (20)

怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
Charbagh + Female Escorts Service in Lucknow | Starting ₹,5K To @25k with A/C...
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
Sonagachi * best call girls in Kolkata | ₹,9500 Pay Cash 8005736733 Free Home...
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book nowVadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
Vadodara 💋 Call Girl 7737669865 Call Girls in Vadodara Escort service book now
 
Top Call Girls in Balaghat 9332606886Call Girls Advance Cash On Delivery Ser...
Top Call Girls in Balaghat  9332606886Call Girls Advance Cash On Delivery Ser...Top Call Girls in Balaghat  9332606886Call Girls Advance Cash On Delivery Ser...
Top Call Girls in Balaghat 9332606886Call Girls Advance Cash On Delivery Ser...
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Purnia [ 7014168258 ] Call Me For Genuine Models We...
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
 
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With OrangePredicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
Predicting HDB Resale Prices - Conducting Linear Regression Analysis With Orange
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
Sealdah % High Class Call Girls Kolkata - 450+ Call Girl Cash Payment 8005736...
 

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