SlideShare a Scribd company logo
1 of 12
Mongodb is a document-oriented NoSQL database used for high volume data
storage. In this tutorial you will learn how Mongodb can be accessed and some of
its important features like indexing, regular expression, sharding data, etc.
MongoDB is a database which came into light around the mid-2000s. It falls
under the category of a NoSQL database
 MongoDB is a document database. Each database
contains collections which in turn contains
documents. Each document can be different with
varying number of fields. The size and content of
each document can be different from each other.
 The document structure is more in line with how
developers construct their classes and objects in their
respective programming languages. Developers will
often say that their classes are not rows and columns
but have a clear structure with key-value pairs.
 As seen in the introduction with NoSQL databases,
the rows (or documents as called in MongoDB)
doesn't need to have a schema defined beforehand.
Instead, the fields can be created on the fly.
 The data model available within MongoDB
allows you to represent hierarchical
relationships, to store arrays, and other more
complex structures more easily.
 Scalability – The MongoDB environments are
very scalable. Companies across the world
have defined clusters with some of them
running 100+ nodes with around millions of
documents within the database
 In MongoDB, the first basic step is to have a
database and collection in place. The
database is used to store all of the
collections, and the collection in turn is used
to store all of the documents
 The easiest way to create a collection is to
insert a record (which is nothing but a
document consisting of Field names and
Values) into a collection. If the collection does
not exist a new one will be created.
 The following example shows how this can be
done.
 db.Employee.insert ( { "Employeeid" : 1,
"EmployeeName" : "Martin" } )
 By default when inserting documents in the
collection, if you don't add a field name with
the _id in the field name, then MongoDB will
automatically add an Object id field.
 Why do we need the ObjectId field? Well,
MongoDB uses this as the primary key for the
collection so that each document can be
uniquely identified in the collection.
 When explicitly creating an id field, it needs to be created
with _id in its name.
 Let's look at an example on how we can achieve this.
 db.Employee.insert({_id:10, "EmployeeName" : "Smith"})
 Performing Queries
 The method of fetching or getting data from a MongoDB
database is carried out by using queries. While performing
a query operation, one can also use criteria’s or conditions
which can be used to retrieve specific data from the
database.
 MongoDB provides a function called db.collection.find
() which is used for retrieval of documents from a
MongoDB database.
 During the course of this tutorial, you will see how this
function is used in various ways to achieve the purpose of
document retrieval.
 Mongo DB provides query modifiers such as
the 'limit' and 'Orders' clause to provide more
flexibility when executing queries. We will
take a look at the following query modifiers
 Limits
 This modifier is used to limit the number of
documents which are returned in the result
set for a query. The following example shows
how this can be done.
 db.Employee.find().limit(2).forEach(printjson);
 MongoDB provides the insert () command to insert
documents into a collection. The following example
shows how this can be done.
 Step 1) Write the "insert" command
 Step 2) Within the "insert" command, add the required
Field Name and Field Value for the document which
needs to be created.
 One can specify the order of documents to be returned
based on ascending or descending order of any key in
the collection. The following example shows how this
can be done.
 db.Employee.find().sort({Employeeis:-
1}).forEach(printjson)
 MongoDB provides the update() command to update the
documents of a collection. To update only the documents
you want to update, you can add a criteria to the update
statement so that only selected documents are updated.
 The basic parameters in the command is a condition for
which document needs to be updated, and the next is the
modification which needs to be performed.
 The following example shows how this can be done.
 Step 1) Issue the update command
 Step 2) Choose the condition which you want to use to
decide which document needs to be updated. In our
example, we want to update the document which has the
Employee id 22.
 Step 3) Use the set command to modify the Field Name
 Step 4) Choose which Field Name you want to modify and
enter the new value accordingly.
 db.Employee.update( {"Employeeid" : 1}, {$set: {
"EmployeeName" : "NewMartin"}});
 Updating Multiple Values
 To ensure that multiple documents are updated
at the same time in MongoDB you need to use
the multi option because otherwise by default
only one document is modified at a time.
 The following example shows how this can be
done.
 In this example, we are going to first find the
document which has the Employee id as "1" and
change the Employee name from "Martin" to
"NewMartin"
 db.Employee.update
 ( { Employeeid : 1 },
 { $set :
 { "EmployeeName" : "NewMartin" "Employeeid"
: 22 }
 }
 )

More Related Content

What's hot

MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010
Eliot Horowitz
 
Introduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDBIntroduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDB
Behrouz Bakhtiari
 

What's hot (17)

MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010MongoDB Java Development - MongoBoston 2010
MongoDB Java Development - MongoBoston 2010
 
MongoDB
MongoDBMongoDB
MongoDB
 
Aggregation Framework in MongoDB Overview Part-1
Aggregation Framework in MongoDB Overview Part-1Aggregation Framework in MongoDB Overview Part-1
Aggregation Framework in MongoDB Overview Part-1
 
Webinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDBWebinar: Transitioning from SQL to MongoDB
Webinar: Transitioning from SQL to MongoDB
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDBIntroduction to NOSQL And MongoDB
Introduction to NOSQL And MongoDB
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Mongo indexes
Mongo indexesMongo indexes
Mongo indexes
 
Reducing Development Time with MongoDB vs. SQL
Reducing Development Time with MongoDB vs. SQLReducing Development Time with MongoDB vs. SQL
Reducing Development Time with MongoDB vs. SQL
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 
Introduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUWIntroduction to MongoDB at IGDTUW
Introduction to MongoDB at IGDTUW
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
Indexing with MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
 
MongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced AggregationMongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced Aggregation
 
Storing tree structures with MongoDB
Storing tree structures with MongoDBStoring tree structures with MongoDB
Storing tree structures with MongoDB
 

Viewers also liked (6)

19thfebconnectingbristolfinalbidpresentation
19thfebconnectingbristolfinalbidpresentation19thfebconnectingbristolfinalbidpresentation
19thfebconnectingbristolfinalbidpresentation
 
Smart City Benchmark
Smart City BenchmarkSmart City Benchmark
Smart City Benchmark
 
Digital City Bristol
Digital City BristolDigital City Bristol
Digital City Bristol
 
Open data portal presentation by Mark Newman (Bristol City Council)
Open data portal presentation by Mark Newman (Bristol City Council) Open data portal presentation by Mark Newman (Bristol City Council)
Open data portal presentation by Mark Newman (Bristol City Council)
 
Bristol smart city report
Bristol smart city reportBristol smart city report
Bristol smart city report
 
Bristol Approach To Citizen Sensing
Bristol Approach To Citizen SensingBristol Approach To Citizen Sensing
Bristol Approach To Citizen Sensing
 

Similar to Mongo db

Similar to Mongo db (20)

Unit 1 NoSQL commands.pptx
Unit 1 NoSQL commands.pptxUnit 1 NoSQL commands.pptx
Unit 1 NoSQL commands.pptx
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
unit 4,Indexes in database.docx
unit 4,Indexes in database.docxunit 4,Indexes in database.docx
unit 4,Indexes in database.docx
 
MongoDB
MongoDBMongoDB
MongoDB
 
Mongodb Introduction
Mongodb IntroductionMongodb Introduction
Mongodb Introduction
 
Mongodb By Vipin
Mongodb By VipinMongodb By Vipin
Mongodb By Vipin
 
The emerging world of mongo db csp
The emerging world of mongo db   cspThe emerging world of mongo db   csp
The emerging world of mongo db csp
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 
MongoDB
MongoDBMongoDB
MongoDB
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDB
 
Query Optimization in MongoDB
Query Optimization in MongoDBQuery Optimization in MongoDB
Query Optimization in MongoDB
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
Mongodb Introduction
Mongodb Introduction Mongodb Introduction
Mongodb Introduction
 
UNIT-1 MongoDB.pptx
UNIT-1 MongoDB.pptxUNIT-1 MongoDB.pptx
UNIT-1 MongoDB.pptx
 
MongoDB-presentation.pptx
MongoDB-presentation.pptxMongoDB-presentation.pptx
MongoDB-presentation.pptx
 

More from Ramakrishna kapa

More from Ramakrishna kapa (20)

Load balancer in mule
Load balancer in muleLoad balancer in mule
Load balancer in mule
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
 
Batch processing
Batch processingBatch processing
Batch processing
 
Msmq connectivity
Msmq connectivityMsmq connectivity
Msmq connectivity
 
Scopes in mule
Scopes in muleScopes in mule
Scopes in mule
 
Data weave more operations
Data weave more operationsData weave more operations
Data weave more operations
 
Basic math operations using dataweave
Basic math operations using dataweaveBasic math operations using dataweave
Basic math operations using dataweave
 
Dataweave types operators
Dataweave types operatorsDataweave types operators
Dataweave types operators
 
Operators in mule dataweave
Operators in mule dataweaveOperators in mule dataweave
Operators in mule dataweave
 
Data weave in mule
Data weave in muleData weave in mule
Data weave in mule
 
Servicenow connector
Servicenow connectorServicenow connector
Servicenow connector
 
Introduction to testing mule
Introduction to testing muleIntroduction to testing mule
Introduction to testing mule
 
Choice flow control
Choice flow controlChoice flow control
Choice flow control
 
Message enricher example
Message enricher exampleMessage enricher example
Message enricher example
 
Mule exception strategies
Mule exception strategiesMule exception strategies
Mule exception strategies
 
Anypoint connector basics
Anypoint connector basicsAnypoint connector basics
Anypoint connector basics
 
Mule global elements
Mule global elementsMule global elements
Mule global elements
 
Mule message structure and varibles scopes
Mule message structure and varibles scopesMule message structure and varibles scopes
Mule message structure and varibles scopes
 
How to create an api in mule
How to create an api in muleHow to create an api in mule
How to create an api in mule
 
Log4j is a reliable, fast and flexible
Log4j is a reliable, fast and flexibleLog4j is a reliable, fast and flexible
Log4j is a reliable, fast and flexible
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+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...
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
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
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

Mongo db

  • 1. Mongodb is a document-oriented NoSQL database used for high volume data storage. In this tutorial you will learn how Mongodb can be accessed and some of its important features like indexing, regular expression, sharding data, etc. MongoDB is a database which came into light around the mid-2000s. It falls under the category of a NoSQL database
  • 2.  MongoDB is a document database. Each database contains collections which in turn contains documents. Each document can be different with varying number of fields. The size and content of each document can be different from each other.  The document structure is more in line with how developers construct their classes and objects in their respective programming languages. Developers will often say that their classes are not rows and columns but have a clear structure with key-value pairs.  As seen in the introduction with NoSQL databases, the rows (or documents as called in MongoDB) doesn't need to have a schema defined beforehand. Instead, the fields can be created on the fly.
  • 3.  The data model available within MongoDB allows you to represent hierarchical relationships, to store arrays, and other more complex structures more easily.  Scalability – The MongoDB environments are very scalable. Companies across the world have defined clusters with some of them running 100+ nodes with around millions of documents within the database
  • 4.  In MongoDB, the first basic step is to have a database and collection in place. The database is used to store all of the collections, and the collection in turn is used to store all of the documents
  • 5.  The easiest way to create a collection is to insert a record (which is nothing but a document consisting of Field names and Values) into a collection. If the collection does not exist a new one will be created.  The following example shows how this can be done.  db.Employee.insert ( { "Employeeid" : 1, "EmployeeName" : "Martin" } )
  • 6.  By default when inserting documents in the collection, if you don't add a field name with the _id in the field name, then MongoDB will automatically add an Object id field.  Why do we need the ObjectId field? Well, MongoDB uses this as the primary key for the collection so that each document can be uniquely identified in the collection.
  • 7.  When explicitly creating an id field, it needs to be created with _id in its name.  Let's look at an example on how we can achieve this.  db.Employee.insert({_id:10, "EmployeeName" : "Smith"})  Performing Queries  The method of fetching or getting data from a MongoDB database is carried out by using queries. While performing a query operation, one can also use criteria’s or conditions which can be used to retrieve specific data from the database.  MongoDB provides a function called db.collection.find () which is used for retrieval of documents from a MongoDB database.  During the course of this tutorial, you will see how this function is used in various ways to achieve the purpose of document retrieval.
  • 8.  Mongo DB provides query modifiers such as the 'limit' and 'Orders' clause to provide more flexibility when executing queries. We will take a look at the following query modifiers  Limits  This modifier is used to limit the number of documents which are returned in the result set for a query. The following example shows how this can be done.  db.Employee.find().limit(2).forEach(printjson);
  • 9.  MongoDB provides the insert () command to insert documents into a collection. The following example shows how this can be done.  Step 1) Write the "insert" command  Step 2) Within the "insert" command, add the required Field Name and Field Value for the document which needs to be created.  One can specify the order of documents to be returned based on ascending or descending order of any key in the collection. The following example shows how this can be done.  db.Employee.find().sort({Employeeis:- 1}).forEach(printjson)
  • 10.  MongoDB provides the update() command to update the documents of a collection. To update only the documents you want to update, you can add a criteria to the update statement so that only selected documents are updated.  The basic parameters in the command is a condition for which document needs to be updated, and the next is the modification which needs to be performed.  The following example shows how this can be done.  Step 1) Issue the update command  Step 2) Choose the condition which you want to use to decide which document needs to be updated. In our example, we want to update the document which has the Employee id 22.  Step 3) Use the set command to modify the Field Name  Step 4) Choose which Field Name you want to modify and enter the new value accordingly.
  • 11.  db.Employee.update( {"Employeeid" : 1}, {$set: { "EmployeeName" : "NewMartin"}});  Updating Multiple Values  To ensure that multiple documents are updated at the same time in MongoDB you need to use the multi option because otherwise by default only one document is modified at a time.  The following example shows how this can be done.  In this example, we are going to first find the document which has the Employee id as "1" and change the Employee name from "Martin" to "NewMartin"
  • 12.  db.Employee.update  ( { Employeeid : 1 },  { $set :  { "EmployeeName" : "NewMartin" "Employeeid" : 22 }  }  )