SlideShare a Scribd company logo
Build innovative modern applications that
create a competitive advantage.
Hossein Boustani
Developer
@engboustani
Introducing
• MongoDB is an open-source, document database designed for ease
of development and scaling.
Database Types
RDBMS
(Relational Database
Management System)
SQL Server, Mysql, Oracle
NoSQL
(Non-relational
Operational Stores)
MangoDB, Cassandra, Redis
Document-oriented database
• Document-oriented databases are inherently a subclass of the
key-value store, another NoSQL database concept.
• Document databases contrast strongly with the traditional relational
database (RDB):
• Relational databases generally store data in separate tables that are defined
by the programmer, and a single object may be spread across several tables.
• Document databases store all information for a given object in a single
instance in the database, and every stored object can be different from every
other.
Database Landscape
Memcached
MongoDB
RDBMS
Depth of Functionality
Scalability&Performance
Terminology
RDBMS MongoDB
Table, View Collection
Row Document
Index Index
Join Embedded Document
Foreign Key Reference
Partition Shard
Features
• Documents are stored in BSON (binary JSON)
• Rich, javascript-based query syntax
• Allows us to deep, nested queries
• Efficient binary large object store via GridFS
• i.e. store images, videos, anything
Let’s Build a Blog with MongoDB
• Entities in our Blogging System:
• Users
• Articles
• Comments
• Tags
• Categories
Typical (relational) ERD
Category
• Name
• URL
Tag
• Name
• URL
Comment
• Comment
• Date
• Author
User
• Name
• Email Address
Article
• Name
• Slug
• Publish Date
• Text
MongoDB ERD
Article
• Name
• Slug
• Publish Date
• Text
• Author
Comment[]
• Comment
• Date
• Author
Tag[]
• Value
Category[]
• Value
User
• Name
• Email Address
BSON
• BSON is a computer data interchange format used mainly as a data
storage and network transfer format in the MongoDB database. It is a
binary form for representing simple data structures, associative
arrays (called objects or documents in MongoDB), and various data
types of specific interest to MongoDB. The name "BSON" is based on
the term JSON and stands for "Binary JSON".
Start with an object (or array, hash, dict, etc)
> var user = {
username: ‘eng.boustani’,
first_name: ‘Hossein’,
last_name: ‘Boustani’
}
Insert the Record
> db
test
> use blog
switched to db blog
// syntax is db.<collection>.<command>
> db.users.insert(user)
Retrieve the Record again
// get one document (don’t care which one)
> db.users.findOne()
{
"_id" : ObjectId("50804d0bd94ccab2da652599"),
"username" : "eng.boustani",
"first_name" : "Hossein",
"last_name" : "Boustani"
}
_id
• _id is the primary key in MongoDB
• Any unique immutable value could be used
• Automatically created as an ObjectId if not provided
• Automatically indexed
ObjectId
• ObjectId is a special 12 byte value
• Guaranteed to be unique across your cluster
• ObjectId("50804d0bd94ccab2da652599")
ts mac pid inc
Creating a Blog Article
> db.articles.insert({
title: ‘Hello World’,
body: ‘This is my first blog post’,
date: new Date(‘2013-06-20’),
username: ‘eng.boustani’,
tags: [‘adventure’, ‘mongodb’],
comments: [ ]
})
Finding the Article
> db.articles.find().pretty()
{
"_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-06-20T00:00:00Z"),
"username" : "eng.boustani",
"tags" : [ "adventure", "mongodb"],
"comments" : [ ]
}
Finding the Article
> db.articles.find({
_id : ObjectId("51c3bafafbd5d7261b4cdb5a")
}).pretty()
{
"_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-06-20T00:00:00Z"),
"username" : "eng.boustani",
"tags" : [ "adventure", "mongodb"],
"comments" : [ ]
}
Querying An Array
> db.articles.find({ tags : ‘adventure’ }).pretty()
{
"_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"),
"title" : "Hello World",
"body" : "This is my first blog post",
"date" : ISODate("2013-06-20T00:00:00Z"),
"username" : "eng.boustani",
"tags" : [ "adventure", "mongodb"],
"comments" : [ ]
}
Using Update to Add a Comment
// the syntax is: update( what, how)
> db.articles.update({
_id: ObjectId("51c3bcddfbd5d7261b4cdb5b")
}, {
"$push" : {
"comments" : {
"name" : "Asghar Sohrabi",
"comment" : "Awesome Post"
}
})
Article with Comment Embedded
> db.articles.find({ username: "eng.boustani" }).pretty()
{
"_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"),
"body" : "This is my first blog post",
"comments" : [
{
"name" : "Asghar Sohrabi",
"comment" : "Awesome Post"
}
],
"date" : ISODate("2013-06-20T00:00:00Z"),
"tags" : ["adventure", "mongodb"],
"title" : "Hello World",
"username" : "eng.boustani"
}
Remove Comments / Articles
// remove comment with $pull
> var last_comment = {
"name" : "Asghar Sohrabi",
"comment" : "Awesome Post"
}
> db.articles.update({
_id: ObjectId("51c3bcddfbd5d7261b4cdb5b")
}, {
$pull : { comments: last_comment }
})
// remove article
> db.articles.remove({
_id: ObjectId("51c3bcddfbd5d7261b4cdb5b")
})
MongoDB Drivers
• MongoDB has native bindings for over 12 languages
MongoDB Tools
• Robomongo
• MongoDB Compass
• MongoDB Cloud Manager
• MongoMonitor
Some Companies using MongoDB
Book
MongoDB: The Definitive Guide
Kristina Chodorow
Book
MongoDB and Python
Niall O'Higgins
Book
PHP and MongoDB Web
Development
Rubayeet Islam
Resources
• mongodb.org
• tutorialspoint.com/mongodb/
• github.com/mongodb/
Question?
Thank You
Your time is limited, so don’t waste it
Living someone else’s life
-Steve Jobs

More Related Content

What's hot (19)

KEY
Schema Design with MongoDB
rogerbodamer
 
PDF
MongoDB Schema Design
Alex Litvinok
 
KEY
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
PPT
MongoDB Schema Design
MongoDB
 
PDF
Mongo DB schema design patterns
joergreichert
 
ODP
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
PPTX
MongoDB Schema Design: Four Real-World Examples
Mike Friedman
 
PPTX
Webinar: Schema Design
MongoDB
 
PPTX
Mongo db workshop # 01
FarhatParveen10
 
PPT
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
PDF
Building your first app with mongo db
MongoDB
 
PPTX
Socialite, the Open Source Status Feed Part 1: Design Overview and Scaling fo...
MongoDB
 
PPTX
Dev Jumpstart: Schema Design Best Practices
MongoDB
 
PPTX
Get expertise with mongo db
Amit Thakkar
 
PDF
Real-time Location Based Social Discovery using MongoDB
Fredrik Björk
 
PPTX
Mondodb
Paulo Fagundes
 
PDF
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB
 
PPTX
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB
 
PPTX
Data Modeling for the Real World
Mike Friedman
 
Schema Design with MongoDB
rogerbodamer
 
MongoDB Schema Design
Alex Litvinok
 
Schema Design by Example ~ MongoSF 2012
hungarianhc
 
MongoDB Schema Design
MongoDB
 
Mongo DB schema design patterns
joergreichert
 
MongoDB - A Document NoSQL Database
Ruben Inoto Soto
 
MongoDB Schema Design: Four Real-World Examples
Mike Friedman
 
Webinar: Schema Design
MongoDB
 
Mongo db workshop # 01
FarhatParveen10
 
Building Your First MongoDB App ~ Metadata Catalog
hungarianhc
 
Building your first app with mongo db
MongoDB
 
Socialite, the Open Source Status Feed Part 1: Design Overview and Scaling fo...
MongoDB
 
Dev Jumpstart: Schema Design Best Practices
MongoDB
 
Get expertise with mongo db
Amit Thakkar
 
Real-time Location Based Social Discovery using MongoDB
Fredrik Björk
 
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
MongoDB
 
MongoDB San Francisco 2013: Data Modeling Examples From the Real World presen...
MongoDB
 
Data Modeling for the Real World
Mike Friedman
 

Viewers also liked (17)

PPSX
FlipChartPowerPoint
Joseph Glade
 
PPSX
Dropbox
ntlfierro
 
PDF
Communicating Science - Buddhi Marambe
STS FORUM 2016
 
PDF
Design portfolio
Vincent Luna
 
PPTX
Educacion sexual en la adolescencia. Gonzalo Bellochio, comision Jueves de 18...
Gonzalo Bellochio
 
PDF
Innovation plan uganda
SUN Civil Society Network
 
PDF
Innovation plan malawi
SUN Civil Society Network
 
DOCX
Partes del computador luis
luisf18
 
PDF
Leidyy
leidyandrea15
 
PPTX
trabajo colaborativo
Facundo Flores
 
DOCX
La Felina Uchiha Capitulo 1
KairosX
 
PPTX
Bailando Por Un Sueño 2011 PERUAI
Lucho Brunelli
 
DOCX
Proyecto de vida
CARLOS RAMIREZ
 
PDF
Cam padres drogas_de_sintesis
Candelariaaaa
 
PDF
Car care
Mike Stringer
 
PPTX
Presentación introducción curso Estudios CTS
Juan Mojica
 
PDF
SECURITY FOR DEVOPS DEPLOYMENT PROCESSES: DEFENSES, RISKS, RESEARCH DIRECTIONS
ijseajournal
 
FlipChartPowerPoint
Joseph Glade
 
Dropbox
ntlfierro
 
Communicating Science - Buddhi Marambe
STS FORUM 2016
 
Design portfolio
Vincent Luna
 
Educacion sexual en la adolescencia. Gonzalo Bellochio, comision Jueves de 18...
Gonzalo Bellochio
 
Innovation plan uganda
SUN Civil Society Network
 
Innovation plan malawi
SUN Civil Society Network
 
Partes del computador luis
luisf18
 
trabajo colaborativo
Facundo Flores
 
La Felina Uchiha Capitulo 1
KairosX
 
Bailando Por Un Sueño 2011 PERUAI
Lucho Brunelli
 
Proyecto de vida
CARLOS RAMIREZ
 
Cam padres drogas_de_sintesis
Candelariaaaa
 
Car care
Mike Stringer
 
Presentación introducción curso Estudios CTS
Juan Mojica
 
SECURITY FOR DEVOPS DEPLOYMENT PROCESSES: DEFENSES, RISKS, RESEARCH DIRECTIONS
ijseajournal
 
Ad

Similar to Introduction to MongoDB (20)

PPTX
Webinar: Building Your First MongoDB App
MongoDB
 
PPT
Tech Gupshup Meetup On MongoDB - 24/06/2016
Mukesh Tilokani
 
PDF
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
PPTX
MongoDB (Advanced)
TO THE NEW | Technology
 
PPTX
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
PDF
The emerging world of mongo db csp
Carlos Sánchez Pérez
 
PDF
Mongo db eveningschemadesign
MongoDB APAC
 
PDF
Building your first app with MongoDB
Norberto Leite
 
PPTX
Introduction to MongoDB
S.Shayan Daneshvar
 
PPTX
mongodb introduction11111111111111111111
VADAPALLYPRAVEENKUMA1
 
KEY
Introduction to MongoDB
Alex Bilbie
 
PDF
Building Your First MongoDB Application
Tugdual Grall
 
PDF
Building Your First MongoDB App
Henrik Ingo
 
PDF
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
PPTX
lecture_34e.pptx
janibashashaik25
 
PDF
MongoDB
techwhizbang
 
PPTX
Building Your First Application with MongoDB
MongoDB
 
PDF
Mongodb Introduction
Raghvendra Parashar
 
PPTX
MongoDB by Emroz sardar.
Emroz Sardar
 
KEY
MongoDB Strange Loop 2009
Mike Dirolf
 
Webinar: Building Your First MongoDB App
MongoDB
 
Tech Gupshup Meetup On MongoDB - 24/06/2016
Mukesh Tilokani
 
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
MongoDB (Advanced)
TO THE NEW | Technology
 
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
The emerging world of mongo db csp
Carlos Sánchez Pérez
 
Mongo db eveningschemadesign
MongoDB APAC
 
Building your first app with MongoDB
Norberto Leite
 
Introduction to MongoDB
S.Shayan Daneshvar
 
mongodb introduction11111111111111111111
VADAPALLYPRAVEENKUMA1
 
Introduction to MongoDB
Alex Bilbie
 
Building Your First MongoDB Application
Tugdual Grall
 
Building Your First MongoDB App
Henrik Ingo
 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
 
lecture_34e.pptx
janibashashaik25
 
MongoDB
techwhizbang
 
Building Your First Application with MongoDB
MongoDB
 
Mongodb Introduction
Raghvendra Parashar
 
MongoDB by Emroz sardar.
Emroz Sardar
 
MongoDB Strange Loop 2009
Mike Dirolf
 
Ad

Recently uploaded (20)

PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 

Introduction to MongoDB

  • 1. Build innovative modern applications that create a competitive advantage.
  • 3. Introducing • MongoDB is an open-source, document database designed for ease of development and scaling.
  • 4. Database Types RDBMS (Relational Database Management System) SQL Server, Mysql, Oracle NoSQL (Non-relational Operational Stores) MangoDB, Cassandra, Redis
  • 5. Document-oriented database • Document-oriented databases are inherently a subclass of the key-value store, another NoSQL database concept. • Document databases contrast strongly with the traditional relational database (RDB): • Relational databases generally store data in separate tables that are defined by the programmer, and a single object may be spread across several tables. • Document databases store all information for a given object in a single instance in the database, and every stored object can be different from every other.
  • 6. Database Landscape Memcached MongoDB RDBMS Depth of Functionality Scalability&Performance
  • 7. Terminology RDBMS MongoDB Table, View Collection Row Document Index Index Join Embedded Document Foreign Key Reference Partition Shard
  • 8. Features • Documents are stored in BSON (binary JSON) • Rich, javascript-based query syntax • Allows us to deep, nested queries • Efficient binary large object store via GridFS • i.e. store images, videos, anything
  • 9. Let’s Build a Blog with MongoDB • Entities in our Blogging System: • Users • Articles • Comments • Tags • Categories
  • 10. Typical (relational) ERD Category • Name • URL Tag • Name • URL Comment • Comment • Date • Author User • Name • Email Address Article • Name • Slug • Publish Date • Text
  • 11. MongoDB ERD Article • Name • Slug • Publish Date • Text • Author Comment[] • Comment • Date • Author Tag[] • Value Category[] • Value User • Name • Email Address
  • 12. BSON • BSON is a computer data interchange format used mainly as a data storage and network transfer format in the MongoDB database. It is a binary form for representing simple data structures, associative arrays (called objects or documents in MongoDB), and various data types of specific interest to MongoDB. The name "BSON" is based on the term JSON and stands for "Binary JSON".
  • 13. Start with an object (or array, hash, dict, etc) > var user = { username: ‘eng.boustani’, first_name: ‘Hossein’, last_name: ‘Boustani’ }
  • 14. Insert the Record > db test > use blog switched to db blog // syntax is db.<collection>.<command> > db.users.insert(user)
  • 15. Retrieve the Record again // get one document (don’t care which one) > db.users.findOne() { "_id" : ObjectId("50804d0bd94ccab2da652599"), "username" : "eng.boustani", "first_name" : "Hossein", "last_name" : "Boustani" }
  • 16. _id • _id is the primary key in MongoDB • Any unique immutable value could be used • Automatically created as an ObjectId if not provided • Automatically indexed
  • 17. ObjectId • ObjectId is a special 12 byte value • Guaranteed to be unique across your cluster • ObjectId("50804d0bd94ccab2da652599") ts mac pid inc
  • 18. Creating a Blog Article > db.articles.insert({ title: ‘Hello World’, body: ‘This is my first blog post’, date: new Date(‘2013-06-20’), username: ‘eng.boustani’, tags: [‘adventure’, ‘mongodb’], comments: [ ] })
  • 19. Finding the Article > db.articles.find().pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : "eng.boustani", "tags" : [ "adventure", "mongodb"], "comments" : [ ] }
  • 20. Finding the Article > db.articles.find({ _id : ObjectId("51c3bafafbd5d7261b4cdb5a") }).pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : "eng.boustani", "tags" : [ "adventure", "mongodb"], "comments" : [ ] }
  • 21. Querying An Array > db.articles.find({ tags : ‘adventure’ }).pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : "eng.boustani", "tags" : [ "adventure", "mongodb"], "comments" : [ ] }
  • 22. Using Update to Add a Comment // the syntax is: update( what, how) > db.articles.update({ _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") }, { "$push" : { "comments" : { "name" : "Asghar Sohrabi", "comment" : "Awesome Post" } })
  • 23. Article with Comment Embedded > db.articles.find({ username: "eng.boustani" }).pretty() { "_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"), "body" : "This is my first blog post", "comments" : [ { "name" : "Asghar Sohrabi", "comment" : "Awesome Post" } ], "date" : ISODate("2013-06-20T00:00:00Z"), "tags" : ["adventure", "mongodb"], "title" : "Hello World", "username" : "eng.boustani" }
  • 24. Remove Comments / Articles // remove comment with $pull > var last_comment = { "name" : "Asghar Sohrabi", "comment" : "Awesome Post" } > db.articles.update({ _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") }, { $pull : { comments: last_comment } }) // remove article > db.articles.remove({ _id: ObjectId("51c3bcddfbd5d7261b4cdb5b") })
  • 25. MongoDB Drivers • MongoDB has native bindings for over 12 languages
  • 26. MongoDB Tools • Robomongo • MongoDB Compass • MongoDB Cloud Manager • MongoMonitor
  • 28. Book MongoDB: The Definitive Guide Kristina Chodorow
  • 30. Book PHP and MongoDB Web Development Rubayeet Islam
  • 33. Thank You Your time is limited, so don’t waste it Living someone else’s life -Steve Jobs