SlideShare a Scribd company logo
MongoDB
Ram Murat Sharma | @rammrms | rammurat.rms.sharma0@gmail.com
Agenda
 Prerequisite
 Introduction to MongoDB
 MongoDB vs RDBMS Structure
 Basic CRUD Operations
 Create, Update, Delete & Drop
 Sort, Limit & Indexing
 Where Clause
 Aggregation()
 Connect with Node
 Sharding
 Replication
 Backup/Restore Data
 Access MongoDB with Server Side language (Node)
 Why MongoDB?
 Questions
Prerequisites
 What you should know already
 Basic knowledge of JavaScript
 Basic knowledge of Server Side language
 Good knowledge of JSON
 Good knowledge of Database
 Technical preparations
 Any browser running on your laptop/Desktop
 Any server side language running like PHP, Node etc.
 Your IDE or code editor of choice
 Any server running to respond query like Tomcat, Xampp or
Node
Introduction to MongoDB
MongoDB is a cross-platform, document oriented
database that provides, high performance, high
availability, and easy scalability.
Key Structure
 Database - Database is a physical container for collections. Each database
gets its own set of files on the file system.
 Collection - Collection is a group of MongoDB documents. It is the equivalent
of an RDBMS table. A collection exists within a single database. Documents
within a collection can have different fields. Typically, all documents in a
collection are of similar or related purpose.
 Document - A document is a set of key-value pairs. Documents have dynamic
schema. Dynamic schema means that documents in the same collection do
not need to have the same set of fields or structure.
RDBMS MongoDB
Database Database
Table Collection
Row Document
Column Field
Join Embedded Documents
Primary Key _id (Provided by MongoDB)
Database Server and Client
MySqlD/Oracle mongoD
MySql/SqlPlus mongo
RDBMS VS MongoDB
Structure Example
SQL No SQL
Basic Commands
Operation Command
Create Database Use <dbname>
Switch Database Use <dbname>
List current Database Db
List all databases Show dbs
Drop Database Db.dropDatabase()
Create Collection db.createCollection(name, options)
db.createCollection(“Sapient”, {max:1000})
List collection Show collections
Drop Collection db.COLLECTION_NAME.drop()
Operation Command
Insert Document db.COLLECTION_NAME.insert(document)
db.employees.insert({
‘title’: ‘Associate L2',
‘oracle_id’: 104495,
‘education’: [‘BCA', ‘MCA'],
‘projects’:{ ‘id’:232323,’Strengh’:60 }
})
Update Document db.COLLECTION_NAME.update(SELECTIOIN_C
RITERIA, UPDATED_DATA)
db.employees.update(
{ ‘oracle_id’: 104495},
{ $set: {‘title’: ‘Senior Associate L2’}}
)
Delete Document(s)
Delete one record from result set in case
multiple records
db.COLLECTION_NAME.remove(DELLETION_C
RITTERIA)
db.employees.remove({'title':‘Associate L2'})
db.employees.remove({'title':‘Associate L2'},1)
Operation Command
Empty Document db.COLLECTION_NAME.remove()
Find Document(s) db.COLLECTION_NAME.find()
db.employees.find()
db.employees.find().pretty()
db.employees.find(
{ ‘oracle_id’: 104495}
).pretty()
Find (Projection)
Limit the result set
db.COLLECTION_NAME.find({},{KEY:1})
Where Clause in MongoDB
Operation MongoDB RDBMS
Equality db.employees.find({“salary":“5000"}) where ‘salary ‘= ‘5000’
Less Than db.employees.find({“age":{$lt:30}}) where age < 30
Less Than
Equals
db.employees.find({“age":{$lte:30}}) where age <= 30
Greater Than db.employees.find({“age":{$gt:30}}) where age > 30
Greater Than
Equals
db.employees.find({“age":{$gte:30}}) where age >= 30
Not Equals db.employees.find({“age":{$ne:30}}) where age != 30
Operation Command
Sorting
(1 Asc)
(-1 Desc)
db.COLLECTION_NAME.find().sort({KEY:1})
db.employees.find({"title":’Associate L2’}).sort({‘title’:1})
Limit records db.COLLECTION_NAME.find().limit(NUMBER)
db.employees.find({"title":’Associate L2’}).limit(2)
Skip records db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)
db.employees.find({"title":’Associate L2’}).skip(1)
Indexing db.COLLECTION_NAME.ensureIndex({KEY:1})
db.employees.ensureIndex({"title":1})
Aggregation()
Aggregations operations process data records and return computed
results. Aggregation operations group values from multiple
documents together, and can perform a variety of operations on the
grouped data to return a single result. In sql, count(*) and “group
by” is an equivalent of mongodb aggregation.
 Syntax - db.employees.aggregate([{$group : {_id :
"$oracle_id", title : {$sum : 1}}}])
 Options - $avg, $min, $max, $push , $first & $last
Connect with NODE
MongoDB Dump/Restore
To create backup of database in mongodb you should
use mongodump command. This command will dump all data of
your server into dump directory. There are many options available
by which you can limit the amount of data or create backup of your
remote server.
 Steps:
 Make sure mongo server is running
 Go to bin Mongo bin/ directory
 Type mongodump/mongorestore
 Look for bin/dump/ folder, it contains dump data now
Sharding
Sharding is the process of storing data records across multiple
macines and it is MongoDB’s approach to meeting the demands of
data growth.
Problem – As the size of the data increases, a single machine may
not be sufficient to store the data nor provide an acceptable read
and write throughput.
Solution – Sharding this problem with horizontal scaling where you
can add more machines to support data growth and the demands of
read and write operations.
Why Replication?
Replication is the process of synchronizing data across multiple servers.
Replication provides redundancy and increases data availability with
multiple copies of data on different database servers, replication protects
a database from the loss of a single server. Replication also allows you to
recover from hardware failure and service interruptions. With additional
copies of the data, you can dedicate one to disaster recovery, reporting, or
backup.
• To keep your data safe
• High availability of data (24*7)
• Disaster Recovery
• No downtime for maintenance (like backups, index rebuilds,
compaction)
• Read scaling (extra copies to read from)
Replication
Why MongoDB?
 Document Database
 Documents (objects) map nicely to programming language data types.
 Embedded documents and arrays reduce need for joins.
 Dynamic schema
 High Performance
 Embedding makes reads and writes fast.
 Indexes can include keys from embedded documents and arrays.
 High Availability
 Replicated servers with automatic master failover.
 Easy Scalability
 Automatic sharding distributes collection data across machines.
 Consistent reads can be distributed over replicated servers.
 Brands prefers Mongo - FourSquare, Adobe, McAfee, Ebay, Fifa, MetLife, Forbes and
more…
Questions?
&
Feedbacks
Thank You

More Related Content

What's hot

CouchDB
CouchDBCouchDB
CouchDB
Rashmi Agale
 
Introduction à DocumentDB
Introduction à DocumentDBIntroduction à DocumentDB
Introduction à DocumentDB
MSDEVMTL
 
Azure sql database limitations
Azure sql database limitationsAzure sql database limitations
Azure sql database limitations
BRIJESH KUMAR
 
Deep dive into the native multi model database ArangoDB
Deep dive into the native multi model database ArangoDBDeep dive into the native multi model database ArangoDB
Deep dive into the native multi model database ArangoDB
ArangoDB Database
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
Neil Mackenzie
 
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
NoSQLmatters
 
5\9 SSIS 2008R2_Training - DataFlow Basics
5\9 SSIS 2008R2_Training - DataFlow Basics5\9 SSIS 2008R2_Training - DataFlow Basics
5\9 SSIS 2008R2_Training - DataFlow Basics
Pramod Singla
 
Using schemas in parsing xml part 1
Using schemas in parsing xml part 1Using schemas in parsing xml part 1
Using schemas in parsing xml part 1
Alex Fernandez
 
Azure doc db (slideshare)
Azure doc db (slideshare)Azure doc db (slideshare)
Azure doc db (slideshare)
David Green
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDB
ElieHannouch
 
2\9.SSIS 2008R2 _Training - Control Flow
2\9.SSIS 2008R2 _Training - Control Flow2\9.SSIS 2008R2 _Training - Control Flow
2\9.SSIS 2008R2 _Training - Control Flow
Pramod Singla
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
sethfloydjr
 
Cool NoSQL on Azure with DocumentDB
Cool NoSQL on Azure with DocumentDBCool NoSQL on Azure with DocumentDB
Cool NoSQL on Azure with DocumentDB
Jan Hentschel
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
Bishal Khanal
 
JS App Architecture
JS App ArchitectureJS App Architecture
JS App Architecture
Corey Butler
 
7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task
Pramod Singla
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
NodeXperts
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
Rohit Jain
 

What's hot (20)

CouchDB
CouchDBCouchDB
CouchDB
 
Introduction à DocumentDB
Introduction à DocumentDBIntroduction à DocumentDB
Introduction à DocumentDB
 
Azure sql database limitations
Azure sql database limitationsAzure sql database limitations
Azure sql database limitations
 
Deep dive into the native multi model database ArangoDB
Deep dive into the native multi model database ArangoDBDeep dive into the native multi model database ArangoDB
Deep dive into the native multi model database ArangoDB
 
Lecture12
Lecture12Lecture12
Lecture12
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
 
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
Benjamin Guinebertière - Microsoft Azure: Document DB and other noSQL databas...
 
5\9 SSIS 2008R2_Training - DataFlow Basics
5\9 SSIS 2008R2_Training - DataFlow Basics5\9 SSIS 2008R2_Training - DataFlow Basics
5\9 SSIS 2008R2_Training - DataFlow Basics
 
Using schemas in parsing xml part 1
Using schemas in parsing xml part 1Using schemas in parsing xml part 1
Using schemas in parsing xml part 1
 
Azure doc db (slideshare)
Azure doc db (slideshare)Azure doc db (slideshare)
Azure doc db (slideshare)
 
Introduction To MongoDB
Introduction To MongoDBIntroduction To MongoDB
Introduction To MongoDB
 
2\9.SSIS 2008R2 _Training - Control Flow
2\9.SSIS 2008R2 _Training - Control Flow2\9.SSIS 2008R2 _Training - Control Flow
2\9.SSIS 2008R2 _Training - Control Flow
 
MongoDB - An Introduction
MongoDB - An IntroductionMongoDB - An Introduction
MongoDB - An Introduction
 
Cool NoSQL on Azure with DocumentDB
Cool NoSQL on Azure with DocumentDBCool NoSQL on Azure with DocumentDB
Cool NoSQL on Azure with DocumentDB
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
MongoDB
MongoDBMongoDB
MongoDB
 
JS App Architecture
JS App ArchitectureJS App Architecture
JS App Architecture
 
7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task7\9 SSIS 2008R2_Training - Script Task
7\9 SSIS 2008R2_Training - Script Task
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
 

Similar to MongoDB - A next-generation database that lets you create applications never before possible.

MongoDB 3.4 webinar
MongoDB 3.4 webinarMongoDB 3.4 webinar
MongoDB 3.4 webinar
Andrew Morgan
 
Introduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesIntroduction to MongoDB and its best practices
Introduction to MongoDB and its best practices
AshishRathore72
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big Data
Gruter
 
Ado.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworksAdo.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworks
Luis Goldster
 
DBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training PresentationsDBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training Presentations
Srinivas Mutyala
 
HadoopDB
HadoopDBHadoopDB
HadoopDB
Miguel Pastor
 
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
1AP18CS037ShirishKul
 
introtomongodb
introtomongodbintrotomongodb
introtomongodbsaikiran
 
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB  NoSQL database a deep dive -MyWhitePaperMongoDB  NoSQL database a deep dive -MyWhitePaper
MongoDB NoSQL database a deep dive -MyWhitePaper
Rajesh Kumar
 
MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling
Sachin Bhosale
 
fard car.pptx
fard car.pptxfard car.pptx
fard car.pptx
tarungupta276841
 
MongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behlMongoDB using Grails plugin by puneet behl
MongoDB using Grails plugin by puneet behl
TO THE NEW | Technology
 
Deploying MediaWiki On IBM DB2 in The Cloud Presentation
Deploying MediaWiki On IBM DB2 in The Cloud PresentationDeploying MediaWiki On IBM DB2 in The Cloud Presentation
Deploying MediaWiki On IBM DB2 in The Cloud PresentationLeons Petražickis
 
Mongodb
MongodbMongodb
Mongodb
Thiago Veiga
 
Mongodb
MongodbMongodb
Mongodb
Apurva Vyas
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDB
Jeff Douglas
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012Appirio
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
Marco Segato
 
Klevis Mino: MongoDB
Klevis Mino: MongoDBKlevis Mino: MongoDB
Klevis Mino: MongoDB
Carlo Vaccari
 

Similar to MongoDB - A next-generation database that lets you create applications never before possible. (20)

Nosql seminar
Nosql seminarNosql seminar
Nosql seminar
 
MongoDB 3.4 webinar
MongoDB 3.4 webinarMongoDB 3.4 webinar
MongoDB 3.4 webinar
 
Introduction to MongoDB and its best practices
Introduction to MongoDB and its best practicesIntroduction to MongoDB and its best practices
Introduction to MongoDB and its best practices
 
Introduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big DataIntroduction to Apache Tajo: Data Warehouse for Big Data
Introduction to Apache Tajo: Data Warehouse for Big Data
 
Ado.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworksAdo.net &amp; data persistence frameworks
Ado.net &amp; data persistence frameworks
 
DBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training PresentationsDBVersity MongoDB Online Training Presentations
DBVersity MongoDB Online Training Presentations
 
HadoopDB
HadoopDBHadoopDB
HadoopDB
 
MongoDB_ppt.pptx
MongoDB_ppt.pptxMongoDB_ppt.pptx
MongoDB_ppt.pptx
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
 
MongoDB NoSQL database a deep dive -MyWhitePaper
MongoDB  NoSQL database a deep dive -MyWhitePaperMongoDB  NoSQL database a deep dive -MyWhitePaper
MongoDB NoSQL database a deep dive -MyWhitePaper
 
MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling
 
fard car.pptx
fard car.pptxfard car.pptx
fard car.pptx
 
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
 
Deploying MediaWiki On IBM DB2 in The Cloud Presentation
Deploying MediaWiki On IBM DB2 in The Cloud PresentationDeploying MediaWiki On IBM DB2 in The Cloud Presentation
Deploying MediaWiki On IBM DB2 in The Cloud Presentation
 
Mongodb
MongodbMongodb
Mongodb
 
Mongodb
MongodbMongodb
Mongodb
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDB
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
 
Klevis Mino: MongoDB
Klevis Mino: MongoDBKlevis Mino: MongoDB
Klevis Mino: MongoDB
 

Recently uploaded

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 

MongoDB - A next-generation database that lets you create applications never before possible.

  • 1. MongoDB Ram Murat Sharma | @rammrms | rammurat.rms.sharma0@gmail.com
  • 2. Agenda  Prerequisite  Introduction to MongoDB  MongoDB vs RDBMS Structure  Basic CRUD Operations  Create, Update, Delete & Drop  Sort, Limit & Indexing  Where Clause  Aggregation()  Connect with Node  Sharding  Replication  Backup/Restore Data  Access MongoDB with Server Side language (Node)  Why MongoDB?  Questions
  • 3. Prerequisites  What you should know already  Basic knowledge of JavaScript  Basic knowledge of Server Side language  Good knowledge of JSON  Good knowledge of Database  Technical preparations  Any browser running on your laptop/Desktop  Any server side language running like PHP, Node etc.  Your IDE or code editor of choice  Any server running to respond query like Tomcat, Xampp or Node
  • 4. Introduction to MongoDB MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. Key Structure  Database - Database is a physical container for collections. Each database gets its own set of files on the file system.  Collection - Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A collection exists within a single database. Documents within a collection can have different fields. Typically, all documents in a collection are of similar or related purpose.  Document - A document is a set of key-value pairs. Documents have dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure.
  • 5. RDBMS MongoDB Database Database Table Collection Row Document Column Field Join Embedded Documents Primary Key _id (Provided by MongoDB) Database Server and Client MySqlD/Oracle mongoD MySql/SqlPlus mongo RDBMS VS MongoDB
  • 7. Basic Commands Operation Command Create Database Use <dbname> Switch Database Use <dbname> List current Database Db List all databases Show dbs Drop Database Db.dropDatabase() Create Collection db.createCollection(name, options) db.createCollection(“Sapient”, {max:1000}) List collection Show collections Drop Collection db.COLLECTION_NAME.drop()
  • 8. Operation Command Insert Document db.COLLECTION_NAME.insert(document) db.employees.insert({ ‘title’: ‘Associate L2', ‘oracle_id’: 104495, ‘education’: [‘BCA', ‘MCA'], ‘projects’:{ ‘id’:232323,’Strengh’:60 } }) Update Document db.COLLECTION_NAME.update(SELECTIOIN_C RITERIA, UPDATED_DATA) db.employees.update( { ‘oracle_id’: 104495}, { $set: {‘title’: ‘Senior Associate L2’}} ) Delete Document(s) Delete one record from result set in case multiple records db.COLLECTION_NAME.remove(DELLETION_C RITTERIA) db.employees.remove({'title':‘Associate L2'}) db.employees.remove({'title':‘Associate L2'},1)
  • 9. Operation Command Empty Document db.COLLECTION_NAME.remove() Find Document(s) db.COLLECTION_NAME.find() db.employees.find() db.employees.find().pretty() db.employees.find( { ‘oracle_id’: 104495} ).pretty() Find (Projection) Limit the result set db.COLLECTION_NAME.find({},{KEY:1})
  • 10. Where Clause in MongoDB Operation MongoDB RDBMS Equality db.employees.find({“salary":“5000"}) where ‘salary ‘= ‘5000’ Less Than db.employees.find({“age":{$lt:30}}) where age < 30 Less Than Equals db.employees.find({“age":{$lte:30}}) where age <= 30 Greater Than db.employees.find({“age":{$gt:30}}) where age > 30 Greater Than Equals db.employees.find({“age":{$gte:30}}) where age >= 30 Not Equals db.employees.find({“age":{$ne:30}}) where age != 30
  • 11. Operation Command Sorting (1 Asc) (-1 Desc) db.COLLECTION_NAME.find().sort({KEY:1}) db.employees.find({"title":’Associate L2’}).sort({‘title’:1}) Limit records db.COLLECTION_NAME.find().limit(NUMBER) db.employees.find({"title":’Associate L2’}).limit(2) Skip records db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER) db.employees.find({"title":’Associate L2’}).skip(1) Indexing db.COLLECTION_NAME.ensureIndex({KEY:1}) db.employees.ensureIndex({"title":1})
  • 12. Aggregation() Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together, and can perform a variety of operations on the grouped data to return a single result. In sql, count(*) and “group by” is an equivalent of mongodb aggregation.  Syntax - db.employees.aggregate([{$group : {_id : "$oracle_id", title : {$sum : 1}}}])  Options - $avg, $min, $max, $push , $first & $last
  • 13.
  • 15. MongoDB Dump/Restore To create backup of database in mongodb you should use mongodump command. This command will dump all data of your server into dump directory. There are many options available by which you can limit the amount of data or create backup of your remote server.  Steps:  Make sure mongo server is running  Go to bin Mongo bin/ directory  Type mongodump/mongorestore  Look for bin/dump/ folder, it contains dump data now
  • 16. Sharding Sharding is the process of storing data records across multiple macines and it is MongoDB’s approach to meeting the demands of data growth. Problem – As the size of the data increases, a single machine may not be sufficient to store the data nor provide an acceptable read and write throughput. Solution – Sharding this problem with horizontal scaling where you can add more machines to support data growth and the demands of read and write operations.
  • 17. Why Replication? Replication is the process of synchronizing data across multiple servers. Replication provides redundancy and increases data availability with multiple copies of data on different database servers, replication protects a database from the loss of a single server. Replication also allows you to recover from hardware failure and service interruptions. With additional copies of the data, you can dedicate one to disaster recovery, reporting, or backup. • To keep your data safe • High availability of data (24*7) • Disaster Recovery • No downtime for maintenance (like backups, index rebuilds, compaction) • Read scaling (extra copies to read from) Replication
  • 18. Why MongoDB?  Document Database  Documents (objects) map nicely to programming language data types.  Embedded documents and arrays reduce need for joins.  Dynamic schema  High Performance  Embedding makes reads and writes fast.  Indexes can include keys from embedded documents and arrays.  High Availability  Replicated servers with automatic master failover.  Easy Scalability  Automatic sharding distributes collection data across machines.  Consistent reads can be distributed over replicated servers.  Brands prefers Mongo - FourSquare, Adobe, McAfee, Ebay, Fifa, MetLife, Forbes and more…