SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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 🦊
 

Destacado (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
 

Similar a 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
 

Similar a 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
 

Último

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
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
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 

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