SlideShare ist ein Scribd-Unternehmen logo
1 von 20
MongoDB
Ganesh Kunwar
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}] )
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?

Get docs from sp doc library
Get docs from sp doc libraryGet docs from sp doc library
Get docs from sp doc librarySudip Sengupta
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & IntroductionJerwin Roy
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
NGCC 2016 - Support large partitions
NGCC 2016 - Support large partitionsNGCC 2016 - Support large partitions
NGCC 2016 - Support large partitionsRobert Stupp
 
Updating materialized views and caches using kafka
Updating materialized views and caches using kafkaUpdating materialized views and caches using kafka
Updating materialized views and caches using kafkaZach Cox
 
MongoDB - javascript for your data
MongoDB - javascript for your dataMongoDB - javascript for your data
MongoDB - javascript for your dataaaronheckmann
 
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
MySQL Without The SQL -- Oh My! PHP Detroit July 2018MySQL Without The SQL -- Oh My! PHP Detroit July 2018
MySQL Without The SQL -- Oh My! PHP Detroit July 2018Dave Stokes
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...leifwalsh
 
Quick overview on mongo db
Quick overview on mongo dbQuick overview on mongo db
Quick overview on mongo dbEman Mohamed
 
Replicating application data into materialized views
Replicating application data into materialized viewsReplicating application data into materialized views
Replicating application data into materialized viewsZach Cox
 
Mongo db – document oriented database
Mongo db – document oriented databaseMongo db – document oriented database
Mongo db – document oriented databaseWojciech Sznapka
 
MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB
 
Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)Ontico
 

Was ist angesagt? (20)

Get docs from sp doc library
Get docs from sp doc libraryGet docs from sp doc library
Get docs from sp doc library
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
NGCC 2016 - Support large partitions
NGCC 2016 - Support large partitionsNGCC 2016 - Support large partitions
NGCC 2016 - Support large partitions
 
Updating materialized views and caches using kafka
Updating materialized views and caches using kafkaUpdating materialized views and caches using kafka
Updating materialized views and caches using kafka
 
MongoDB - javascript for your data
MongoDB - javascript for your dataMongoDB - javascript for your data
MongoDB - javascript for your data
 
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
MySQL Without The SQL -- Oh My! PHP Detroit July 2018MySQL Without The SQL -- Oh My! PHP Detroit July 2018
MySQL Without The SQL -- Oh My! PHP Detroit July 2018
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Mongo DB 102
Mongo DB 102Mongo DB 102
Mongo DB 102
 
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
A New MongoDB Sharding Architecture for Higher Availability and Better Resour...
 
Tag based sharding presentation
Tag based sharding presentationTag based sharding presentation
Tag based sharding presentation
 
Quick overview on mongo db
Quick overview on mongo dbQuick overview on mongo db
Quick overview on mongo db
 
Replicating application data into materialized views
Replicating application data into materialized viewsReplicating application data into materialized views
Replicating application data into materialized views
 
Mongo db – document oriented database
Mongo db – document oriented databaseMongo db – document oriented database
Mongo db – document oriented database
 
MongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & Tricks
 
Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)Шардинг в MongoDB, Henrik Ingo (MongoDB)
Шардинг в MongoDB, Henrik Ingo (MongoDB)
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
Apache Spark - Aram Mkrtchyan
Apache Spark - Aram MkrtchyanApache Spark - Aram Mkrtchyan
Apache Spark - Aram Mkrtchyan
 
MongoDB - Ekino PHP
MongoDB - Ekino PHPMongoDB - Ekino PHP
MongoDB - Ekino PHP
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 

Andere mochten auch

Building a Social Network with MongoDB
  Building a Social Network with MongoDB  Building a Social Network with MongoDB
Building a Social Network with MongoDBFred Chu
 
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema DesignMongoDB
 
Building LinkedIn's Learning Platform with MongoDB
Building LinkedIn's Learning Platform with MongoDBBuilding LinkedIn's Learning Platform with MongoDB
Building LinkedIn's Learning Platform with MongoDBMongoDB
 
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 ExamplesMike Friedman
 
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 ExamplesLewis Lin 🦊
 

Andere mochten auch (6)

Building a Social Network with MongoDB
  Building a Social Network with MongoDB  Building a Social Network with MongoDB
Building a Social Network with MongoDB
 
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
MongoDB Schema Design (Event: An Evening with MongoDB Houston 3/11/15)
 
MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
Building LinkedIn's Learning Platform with MongoDB
Building LinkedIn's Learning Platform with MongoDBBuilding LinkedIn's Learning Platform with MongoDB
Building LinkedIn's Learning Platform with 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
 
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
 

Ähnlich wie MongoDB

3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdfMarianJRuben
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewAntonio Pintus
 
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 behlTO THE NEW | Technology
 
MongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl AppMongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl AppStennie Steneker
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql DatabasePrashant Gupta
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo dbHemant Sharma
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDBNorberto Leite
 
Accesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformAccesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformLuca Di Fino
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented DatabasesFabio Fumarola
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB Habilelabs
 
Webinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppWebinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppMongoDB
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongoMichael Bright
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and PythonMike Bright
 

Ähnlich wie MongoDB (20)

Mondodb
MondodbMondodb
Mondodb
 
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
 
3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf3-Mongodb and Mapreduce Programming.pdf
3-Mongodb and Mapreduce Programming.pdf
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
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
 
MongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl AppMongoDB Mojo: Building a Basic Perl App
MongoDB Mojo: Building a Basic Perl App
 
Mongodb - NoSql Database
Mongodb - NoSql DatabaseMongodb - NoSql Database
Mongodb - NoSql Database
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
MongoDB
MongoDBMongoDB
MongoDB
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Accesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data PlatformAccesso ai dati con Azure Data Platform
Accesso ai dati con Azure Data Platform
 
9. Document Oriented Databases
9. Document Oriented Databases9. Document Oriented Databases
9. Document Oriented Databases
 
MongoDB
MongoDBMongoDB
MongoDB
 
MongoDB
MongoDBMongoDB
MongoDB
 
Basics of MongoDB
Basics of MongoDB Basics of MongoDB
Basics of MongoDB
 
Webinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB AppWebinar: Building Your First MongoDB App
Webinar: Building Your First MongoDB App
 
2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo2016 feb-23 pyugre-py_mongo
2016 feb-23 pyugre-py_mongo
 
Using MongoDB and Python
Using MongoDB and PythonUsing MongoDB and Python
Using MongoDB and Python
 

Kürzlich hochgeladen

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

MongoDB

  • 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.
  • 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