Getting Started with MongoDB

Michael Redlich
Michael RedlichSystems Analyst, Polymer Physicist at Amateur Computer Group of New Jersey
Getting Started with
MongoDB
Capital District Java Developers Network
January 16, 2014

Michael P. Redlich
@mpredli
about.me/mpredli/
1
Friday, January 17, 14

1
Who’s Mike?
• BS in CS from Rutgers University
• “Petrochemical Research Organization”
• Ai-Logix, Inc. (now AudioCodes)
• Amateur Computer Group of New Jersey
• Publications
• Presentations
2
Friday, January 17, 14

2
Upcoming Events
• Trenton Computer Festival
• March 14-15, 2014
• tcf-nj.org
• Emerging Technologies for the Enterprise
• April 22-23, 2014
• phillyemergingtech.com
3
Friday, January 17, 14

3
Upcoming Events

4
Friday, January 17, 14

4
Objectives
• What is MongoDB?
• What is NoSQL?
• Getting Started with MongoDB
• Basic CRUD Operations
• Live Demos (yea!)
• MongoDB Resources
5
Friday, January 17, 14

5
What is MongoDB? (1)
• “...an open-source document database that

provides high performance, high availability, and
automatic scaling.”

MongoDB Web Site, http://www.mongodb.org/

• It’s name derived from “humongous”
• Written in C++
6
Friday, January 17, 14

6
What is MongoDB? (2)
• “...an open-source database used by

companies of all sizes, across all industries and
for a wide variety of applications. It is an agile
database that allows schemas to change
quickly as applications evolve, while still
providing functionality developers expect from
traditional databases...”

MongoDB Products Web Site, http://www.mongodb.com/products/mongodb/

7
Friday, January 17, 14

7
What is NoSQL?
• Developed to address shortcomings of a

traditional SQL relational database, namely:

• big data
• frequency of access to big data
• performance and scalability
8
Friday, January 17, 14

8
How is MongoDB
Used?

9
Friday, January 17, 14

9
Who is Using
MongoDB?

10
Friday, January 17, 14

10
Features of MongoDB
•

•
•
•
•

Document-Oriented
Storage

•
•

Full Index Support

•
•

Auto-Sharding

Replication and High
Availability

Fast In-Place Updates
Map/Reduce
GridFS
Professional Support by
MongoDB

Querying

11
Friday, January 17, 14

11
Nomenclature (1)
RDBMS

MongoDB

Database

Database

Table

Collection

Row

Document

Index

Index

Join

Embedding & Linking

Foreign Key

Reference
12

Friday, January 17, 14

12
Nomenclature (2)

13
Friday, January 17, 14

13
What is a Document?
• Basic unit of data
• analogous to a row in a RDBMS
• An ordered set of fields (keys) with

associated values stored in BSON format

• similar to JSON
14
Friday, January 17, 14

14
What is BSON?
• “...a binary-encoded serialization of JSON-like
documents.”

BSON Web Site, http://www.bsonspec.org/

• Binary JSON
• Designed to be lightweight, traversable, and
efficient

15
Friday, January 17, 14

15
What is a Collection?
• A group of documents
• analogous to a table in a RDBMS
• Schema-less
16
Friday, January 17, 14

16
Advantages of
Documents
• Documents correspond to native data
types in many programming languages

• Embedded documents and arrays reduce
the need for expensive joins

• Dynamic schema support fluent
polymorphism

17
Friday, January 17, 14

17
Document Structure
{

embedded document

lastName : “Redlich”,
firstName : “Michael”,
email : “mike@redlich.net”
role : {
officer : “President”,

field

sig : “Java Users Group”

value

}
}

18
Friday, January 17, 14

18
Field Names
• Strings
• Cannot contain:
• null
• dots (.)
• dollar sign ($)
• No duplicate field names
19
Friday, January 17, 14

19
Conventions
• Command Prompt ($)
• MySQL prompt (mysql>)
• MongoDB prompt (>)
• Keywords (db, find(), etc.)
• Variables (variable)
20
Friday, January 17, 14

20
Example Database
• ACGNJ Board of Directors:
• lastName
• firstName
• roles (embedded documents)
• tenure
21
Friday, January 17, 14

21
Getting Started
• Download MongoDB
• Create a default data directory
•/data/db
•C:datadb
• Create your first MongoDB database
22
Friday, January 17, 14

22
Starting MongoDB
• Start an instance of the MongoDB server:
$ mongod

• Start an instance of the MongoDB client (a
JavaScript-based shell):

$ mongo

23
Friday, January 17, 14

23
Mongo Shell (1)
• Show the list of shell commands:
> help

• Show the list of databases:
> show dbs

• Show the current database:
> db

24
Friday, January 17, 14

24
Mongo Shell (2)
• Specify the database to use or create:
> use database

• Show the collections within the current
database:

> show collections

• Show the users within the database:
> show users
25
Friday, January 17, 14

25
Mongo Shell (3)
• Show the recent system.profile
entries:

> show profile

• Tab completion
• Command history
26
Friday, January 17, 14

26
Primary Key
• Denoted by a special field, _id
• It can be generated:
• Implicitly:
{_id : ObjectID(value)}
•
• Explicitly:
• {_id : 2 }, { _id : “MPR”}
27
Friday, January 17, 14

27
ObjectIDs
• Default type for _id
• A 12-byte hexadecimal BSON type:

28
Friday, January 17, 14

28
Live Demo!

29
Friday, January 17, 14

29
Create

30
Friday, January 17, 14

30
Create a Database
• Create a database in MySQL:
mysql> CREATE DATABASE database;

• Create a database in MongoDB:
> use database

31
Friday, January 17, 14

31
Create a Collection
• Create a new table in MySQL:
mysql> CREATE TABLE table(column
datatype,...);

• Create a new collection in MongoDB:
>
db.collection.insert({field:value,.
..})

32
Friday, January 17, 14

32
Insert Data
• Insert a row in MySQL:
> INSERT INTO table(column,...)
VALUES(value,...);

• Insert a document in MongoDB:
>
db.collection.insert({field:value,.
..})

33
Friday, January 17, 14

33
Insert Data with Loops
• Insert multiple documents with an array:
> for(int i = 0;i < j;++i)
db.collection.insert({field:array[i
]});

• Insert multiple documents with variable:
> for(int i = 0;i < j;++i)
db.collection.insert({field:i})

34
Friday, January 17, 14

34
Live Demo!

35
Friday, January 17, 14

35
Read

36
Friday, January 17, 14

36
Query (1)
• Retrieve all rows in MySQL:
mysql> SELECT * FROM table;

• Retrieve all documents in MongoDB:
> db.collection.find()

37
Friday, January 17, 14

37
Query (2)
• Retrieve specified columns in MySQL:
mysql> SELECT column1,column2 FROM
table;

• Retrieve specified fields in MongoDB:
> db.collection.find({},
{field1:true,field2:true})

38
Friday, January 17, 14

38
Query (3)
• Retrieve specific rows in MySQL:
mysql> SELECT * FROM table WHERE
column = value;

• Retrieve specific documents in MongoDB:
> db.collection.find({field:value})

39
Friday, January 17, 14

39
Query (4)
• Retrieve specific rows in MySQL:
mysql> SELECT * FROM table WHERE
column = value ORDER BY value ASC;

• Retrieve specific documents in MongoDB:
>
db.collection.find({field:value}).s
ort({field:1})

40
Friday, January 17, 14

40
Query (5)
• Query for multiple documents (returns a
cursor):

> db.collection.find()

• Query for one document (returns a single
document):

> db.collection.findOne()

41
Friday, January 17, 14

41
Query Selectors
• Scalar:
• $ne, $mod, $exists, $type, $lt,
$lte, $gt, $gte

• Vector:
• $in, $nin, $all, $size
42
Friday, January 17, 14

42
Query (6)
• Retrieve specific rows in MySQL:
mysql> SELECT * FROM table WHERE
column != value;

• Retrieve specific documents in MongoDB:
> db.collection.find({field:
{$ne:value}})

43
Friday, January 17, 14

43
Query (7)
• Retrieve specific rows in MySQL:
mysql> SELECT * FROM table WHERE
column1 = value OR column2 = value;

• Retrieve specific documents in MongoDB:
> db.collection.find({$or:
[{field:value},{field:value}])

44
Friday, January 17, 14

44
Query (8)
> db.members.aggregate({$project:
{officer:"$roles.officer"}})

> db.members.find({tenure:
{$gt:ISODate("2014-12-31")}})

> db.members.find({"roles.officer":
{$exists:true}}).sort({"roles.offic
er":1})

45
Friday, January 17, 14

45
Query (9)
>
db.members.find({"roles.director":
{$all:["Director"]}})

>
db.members.find({"roles.committee":
{$in:["Historian","Newsletter"]}})

> db.members.find({roles:{$size:
3}})

46
Friday, January 17, 14

46
Live Demo!

47
Friday, January 17, 14

47
Update

48
Friday, January 17, 14

48
Update (1)
• Update a row in MySQL:
mysql> UPDATE table SET column =
value WHERE id = id;

• Update a document in a MongoDB:
> db.collection.update({_id:value},
{$set:{field:value}},{multi:true})

49
Friday, January 17, 14

49
Update (2)
• Update a row in MySQL:
mysql> UPDATE table SET column1 =
value WHERE column2 > value;

• Update a document in MongoDB:
> db.collection.update({field1:
{$gt:value}},{$set:{field2:value}},
{multi:true})

50
Friday, January 17, 14

50
Update (3)
• Update a document using findOne():
> redlich =
db.members.findOne({lastName:
"Redlich"})
> redlich.roles = [{sig:"Java Users
Group"}]
> db.members.update({lastName:
"Redlich"},redlich)
51
Friday, January 17, 14

51
Atomic Update
Operators
• Scalar:
• $inc, $set, $unset
• Vector:
• $push, $pop, $pull, $pushAll,
$pullAll, $addToSet

52
Friday, January 17, 14

52
Update (4)
> db.members.update({lastName:
"Redlich"},{$set:
{"ISODate("2016-12-31")}})

> db.members.update({"roles.sig"},
{$set:{"roles.sig":"JUG"}})

53
Friday, January 17, 14

53
Delete

54
Friday, January 17, 14

54
Delete (1)
• Delete all rows in MySQL:
mysql> DELETE FROM table;

• Delete all documents in MongoDB:
> db.collection.remove()

55
Friday, January 17, 14

55
Delete (2)
• Delete specific rows in MySQL:
mysql> DELETE FROM table WHERE
column = value;

• Delete specific documents in MongoDB:
>
db.collection.remove({field:value})

56
Friday, January 17, 14

56
Delete (2)
• Delete a MySQL database
mysql> DROP DATABASE database;

• Delete a MongoDB database
> use database
> db.dropDatabase()

57
Friday, January 17, 14

57
Backup/Restore

58
Friday, January 17, 14

58
Export (1)
• Export a collection to a JSON file
• Ensure mongod is running
$ mongoexport --db database -collection collection --out path/
filename.json

59
Friday, January 17, 14

59
Export (2)
• Export a collection to a CSV file
• Ensure mongod is running
• A list of fields is required
$ mongoexport --db database -collection collection --fields
field1,field2,... --csv --out path/
filename.json

60
Friday, January 17, 14

60
Import
• Import a collection from a JSON, CSV, or
TSV file

• Ensure mongod is running
$ mongoimport --db database -collection collection < path/
filename.json

61
Friday, January 17, 14

61
Dump
• Dump a specified MySQL database:
$ mysqldump -u root --opt database
> path.filename.sql

• Dump all MongoDB databases:
• Ensure mongod is not running
$ mongodump --dbpath /data/db --out
path
62
Friday, January 17, 14

62
Live Demo!

63
Friday, January 17, 14

63
Package Components
(1)
• Core Processes
• mongod - core DB process
• mongos - controller & query router
(sharding)

• mongo - interactive JavaScript-based
shell

64
Friday, January 17, 14

64
Package Components
(2)
• Binary Import and Export
• mongodump - creates BSON dump files
• mongorestore - restores BSON dump
files

• bsondump - converts BSON to JSON
• mongooplog - streams oplog entries
65
Friday, January 17, 14

65
Package Components
(3)
• Data Import and Export
• mongoimport - imports JSON, CSV, or
TSV data formats

• mongoexport - exports to JSON, CSV,
or TSV data formats

66
Friday, January 17, 14

66
Package Components
(4)

• Diagnostic Tools
• mongostat - captures database

operations by type (insert, query, etc.)

• mongotop - tracks read/write activity
• mongosniff - provides tracing/sniffing
view into database activity

• mongoperf - performance testing tool
67
Friday, January 17, 14

67
Package Components
(5)
• GridFS
• mongofiles - provides a commandline interaction to a GridFS storage
system

68
Friday, January 17, 14

68
MongoDB Resources
(1)

69
Friday, January 17, 14

69
MongoDB Resources
(2)

• mongodb.org
• docs.mongodb.org
• mongodb.org/books
• mongodb.com/products/mongodb
• mongodb.com/reference
• bsonspec.org
• education.mongodb.com
70
Friday, January 17, 14

70
Thanks!
mike@redlich.net
@mpredli
javasig.org

71
Friday, January 17, 14

71
1 of 71

Recommended

Shell Tips & Tricks by
Shell Tips & TricksShell Tips & Tricks
Shell Tips & TricksMongoDB
1.4K views16 slides
MongoDB Shell Tips & Tricks by
MongoDB Shell Tips & TricksMongoDB Shell Tips & Tricks
MongoDB Shell Tips & TricksMongoDB
8.8K views26 slides
Mastering the MongoDB Javascript Shell by
Mastering the MongoDB Javascript ShellMastering the MongoDB Javascript Shell
Mastering the MongoDB Javascript ShellScott Hernandez
6.7K views20 slides
Latinoware by
LatinowareLatinoware
Latinowarekchodorow
560 views47 slides
C# Development (Sam Corder) by
C# Development (Sam Corder)C# Development (Sam Corder)
C# Development (Sam Corder)MongoSF
1.3K views14 slides
Nodejs a-practical-introduction-oredev by
Nodejs a-practical-introduction-oredevNodejs a-practical-introduction-oredev
Nodejs a-practical-introduction-oredevFelix Geisendörfer
2.9K views59 slides

More Related Content

What's hot

Node.js - As a networking tool by
Node.js - As a networking toolNode.js - As a networking tool
Node.js - As a networking toolFelix Geisendörfer
12.9K views47 slides
Node.js - A practical introduction (v2) by
Node.js  - A practical introduction (v2)Node.js  - A practical introduction (v2)
Node.js - A practical introduction (v2)Felix Geisendörfer
4.7K views77 slides
Nodejs - Should Ruby Developers Care? by
Nodejs - Should Ruby Developers Care?Nodejs - Should Ruby Developers Care?
Nodejs - Should Ruby Developers Care?Felix Geisendörfer
3.8K views52 slides
Nodejs - A quick tour (v5) by
Nodejs - A quick tour (v5)Nodejs - A quick tour (v5)
Nodejs - A quick tour (v5)Felix Geisendörfer
2.8K views58 slides
Redis data modeling examples by
Redis data modeling examplesRedis data modeling examples
Redis data modeling examplesTerry Cho
19.9K views11 slides
Advanced Redis data structures by
Advanced Redis data structuresAdvanced Redis data structures
Advanced Redis data structuresamix3k
16.2K views34 slides

What's hot(20)

Redis data modeling examples by Terry Cho
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
Terry Cho19.9K views
Advanced Redis data structures by amix3k
Advanced Redis data structuresAdvanced Redis data structures
Advanced Redis data structures
amix3k16.2K views
Building Apps with MongoDB by Nate Abele
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
Nate Abele9.3K views
Debugging and Testing ES Systems by Chris Birchall
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES Systems
Chris Birchall6.8K views
MongoDB: How it Works by Mike Dirolf
MongoDB: How it WorksMongoDB: How it Works
MongoDB: How it Works
Mike Dirolf13.5K views
Elasticsearch 설치 및 기본 활용 by 종민 김
Elasticsearch 설치 및 기본 활용Elasticsearch 설치 및 기본 활용
Elasticsearch 설치 및 기본 활용
종민 김19.5K views
ElasticSearch by Luiz Rocha
ElasticSearchElasticSearch
ElasticSearch
Luiz Rocha3.8K views
NoSQL - An introduction to CouchDB by Jonathan Weiss
NoSQL - An introduction to CouchDBNoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDB
Jonathan Weiss1.8K views
CouchDB Open Source Bridge by Chris Anderson
CouchDB Open Source BridgeCouchDB Open Source Bridge
CouchDB Open Source Bridge
Chris Anderson3.4K views
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting by Myles Braithwaite
Apache CouchDB Presentation @ Sept. 2104 GTALUG MeetingApache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Apache CouchDB Presentation @ Sept. 2104 GTALUG Meeting
Myles Braithwaite405 views

Viewers also liked

Art exibition by
Art exibitionArt exibition
Art exibitionmaleemoha
377 views9 slides
Power point Presentation by
Power point PresentationPower point Presentation
Power point PresentationSumesh SV
325 views10 slides
EFFECTS OF SOCIAL MEDIA ON YOUTH by
EFFECTS OF SOCIAL MEDIA ON YOUTHEFFECTS OF SOCIAL MEDIA ON YOUTH
EFFECTS OF SOCIAL MEDIA ON YOUTHYaman Singhania
12.5K views20 slides
Clarke slideshare by
Clarke slideshareClarke slideshare
Clarke slidesharemleigh7
289 views8 slides
The Sleeping Beauty by
The Sleeping BeautyThe Sleeping Beauty
The Sleeping BeautyInés Tarradellas
461 views8 slides
WhoIsFrancisFairley by
WhoIsFrancisFairleyWhoIsFrancisFairley
WhoIsFrancisFairleyFrancis Fairley
268 views7 slides

Viewers also liked(20)

Art exibition by maleemoha
Art exibitionArt exibition
Art exibition
maleemoha377 views
Power point Presentation by Sumesh SV
Power point PresentationPower point Presentation
Power point Presentation
Sumesh SV325 views
EFFECTS OF SOCIAL MEDIA ON YOUTH by Yaman Singhania
EFFECTS OF SOCIAL MEDIA ON YOUTHEFFECTS OF SOCIAL MEDIA ON YOUTH
EFFECTS OF SOCIAL MEDIA ON YOUTH
Yaman Singhania12.5K views
Clarke slideshare by mleigh7
Clarke slideshareClarke slideshare
Clarke slideshare
mleigh7289 views
Paginas libres by INGRID
Paginas libresPaginas libres
Paginas libres
INGRID 413 views
POWER POINT PRESENTATION by Sumesh SV
POWER POINT PRESENTATIONPOWER POINT PRESENTATION
POWER POINT PRESENTATION
Sumesh SV443 views
POWR POINT PRESENTATION by Sumesh SV
POWR POINT PRESENTATIONPOWR POINT PRESENTATION
POWR POINT PRESENTATION
Sumesh SV536 views
University Assignment Literacy Assessment by mforrester
University Assignment Literacy AssessmentUniversity Assignment Literacy Assessment
University Assignment Literacy Assessment
mforrester357 views
Data Structures by Yaman Singhania by Yaman Singhania
Data Structures by Yaman SinghaniaData Structures by Yaman Singhania
Data Structures by Yaman Singhania
Yaman Singhania636 views
Powerpoint Presentation by Sumesh SV
Powerpoint PresentationPowerpoint Presentation
Powerpoint Presentation
Sumesh SV383 views
Classification of Elements Powerpoint Presentation by Computer Careers by Yaman Singhania
Classification of Elements Powerpoint Presentation by Computer CareersClassification of Elements Powerpoint Presentation by Computer Careers
Classification of Elements Powerpoint Presentation by Computer Careers
Yaman Singhania2.1K views
Madhusha B Ed by Sumesh SV
Madhusha B Ed Madhusha B Ed
Madhusha B Ed
Sumesh SV499 views
Kerajaankalingga by Pak Yayak
KerajaankalinggaKerajaankalingga
Kerajaankalingga
Pak Yayak1.9K views
Atomic Structure Powerpoint Presentation by Computer Careers by Yaman Singhania
Atomic Structure Powerpoint Presentation by Computer CareersAtomic Structure Powerpoint Presentation by Computer Careers
Atomic Structure Powerpoint Presentation by Computer Careers
Yaman Singhania7.2K views

Similar to Getting Started with MongoDB

Getting Started with MongoDB (TCF ITPC 2014) by
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Michael Redlich
2.2K views71 slides
Mongodb intro by
Mongodb introMongodb intro
Mongodb introchristkv
4.1K views37 slides
MongoDB: a gentle, friendly overview by
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overviewAntonio Pintus
2.3K views29 slides
Mongo db php_shaken_not_stirred_joomlafrappe by
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappeSpyros Passas
1.2K views36 slides
MongoDB at GUL by
MongoDB at GULMongoDB at GUL
MongoDB at GULIsrael Gutiérrez
424 views39 slides
Getting Started with C++ (TCF 2014) by
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Michael Redlich
1.3K views38 slides

Similar to Getting Started with MongoDB(20)

Getting Started with MongoDB (TCF ITPC 2014) by Michael Redlich
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)
Michael Redlich2.2K views
Mongodb intro by christkv
Mongodb introMongodb intro
Mongodb intro
christkv4.1K views
MongoDB: a gentle, friendly overview by Antonio Pintus
MongoDB: a gentle, friendly overviewMongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
Antonio Pintus2.3K views
Mongo db php_shaken_not_stirred_joomlafrappe by Spyros Passas
Mongo db php_shaken_not_stirred_joomlafrappeMongo db php_shaken_not_stirred_joomlafrappe
Mongo db php_shaken_not_stirred_joomlafrappe
Spyros Passas1.2K views
Getting Started with C++ (TCF 2014) by Michael Redlich
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)
Michael Redlich1.3K views
OSDC 2012 | Building a first application on MongoDB by Ross Lawley by NETWAYS
OSDC 2012 | Building a first application on MongoDB by Ross LawleyOSDC 2012 | Building a first application on MongoDB by Ross Lawley
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS22 views
MongoDB NYC Python by Mike Dirolf
MongoDB NYC PythonMongoDB NYC Python
MongoDB NYC Python
Mike Dirolf877 views
Indexing Strategies to Help You Scale by MongoDB
Indexing Strategies to Help You ScaleIndexing Strategies to Help You Scale
Indexing Strategies to Help You Scale
MongoDB6.5K views
MongoDB Strange Loop 2009 by Mike Dirolf
MongoDB Strange Loop 2009MongoDB Strange Loop 2009
MongoDB Strange Loop 2009
Mike Dirolf1.7K views
Presentation: mongo db & elasticsearch & membase by Ardak Shalkarbayuli
Presentation: mongo db & elasticsearch & membasePresentation: mongo db & elasticsearch & membase
Presentation: mongo db & elasticsearch & membase
Ardak Shalkarbayuli1.1K views
Webinar: Building Your First Application with MongoDB by MongoDB
Webinar: Building Your First Application with MongoDBWebinar: Building Your First Application with MongoDB
Webinar: Building Your First Application with MongoDB
MongoDB6.2K views
Combine Spring Data Neo4j and Spring Boot to quickl by Neo4j
Combine Spring Data Neo4j and Spring Boot to quicklCombine Spring Data Neo4j and Spring Boot to quickl
Combine Spring Data Neo4j and Spring Boot to quickl
Neo4j8.2K views
Starting with MongoDB by DoThinger
Starting with MongoDBStarting with MongoDB
Starting with MongoDB
DoThinger621 views
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ... by MongoDB
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
MongoDB1.7K views
Marc s01 e02-crud-database by MongoDB
Marc s01 e02-crud-databaseMarc s01 e02-crud-database
Marc s01 e02-crud-database
MongoDB604 views
Webinar: General Technical Overview of MongoDB for Dev Teams by MongoDB
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB4.8K views
MongoDB at CodeMash 2.0.1.0 by Mike Dirolf
MongoDB at CodeMash 2.0.1.0MongoDB at CodeMash 2.0.1.0
MongoDB at CodeMash 2.0.1.0
Mike Dirolf4.8K views
Data Processing and Aggregation with MongoDB by MongoDB
Data Processing and Aggregation with MongoDB Data Processing and Aggregation with MongoDB
Data Processing and Aggregation with MongoDB
MongoDB4.4K views

More from Michael Redlich

Getting Started with GitHub by
Getting Started with GitHubGetting Started with GitHub
Getting Started with GitHubMichael Redlich
153 views30 slides
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework by
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based FrameworkMichael Redlich
415 views55 slides
Building Microservices with Helidon: Oracle's New Java Microservices Framework by
Building Microservices with Helidon:  Oracle's New Java Microservices FrameworkBuilding Microservices with Helidon:  Oracle's New Java Microservices Framework
Building Microservices with Helidon: Oracle's New Java Microservices FrameworkMichael Redlich
274 views58 slides
Introduction to Object Oriented Programming & Design Principles by
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesMichael Redlich
377 views59 slides
Getting Started with C++ by
Getting Started with C++Getting Started with C++
Getting Started with C++Michael Redlich
249 views39 slides
C++ Advanced Features by
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced FeaturesMichael Redlich
280 views62 slides

More from Michael Redlich(20)

Building Microservices with Micronaut: A Full-Stack JVM-Based Framework by Michael Redlich
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
Michael Redlich415 views
Building Microservices with Helidon: Oracle's New Java Microservices Framework by Michael Redlich
Building Microservices with Helidon:  Oracle's New Java Microservices FrameworkBuilding Microservices with Helidon:  Oracle's New Java Microservices Framework
Building Microservices with Helidon: Oracle's New Java Microservices Framework
Michael Redlich274 views
Introduction to Object Oriented Programming & Design Principles by Michael Redlich
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
Michael Redlich377 views
Introduction to Object Oriented Programming &amp; Design Principles by Michael Redlich
Introduction to Object Oriented Programming &amp; Design PrinciplesIntroduction to Object Oriented Programming &amp; Design Principles
Introduction to Object Oriented Programming &amp; Design Principles
Michael Redlich117 views
Building Realtime Access to Data Apps with jOOQ by Michael Redlich
Building Realtime Access to Data Apps with jOOQBuilding Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQ
Michael Redlich225 views
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017) by Michael Redlich
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Michael Redlich281 views
Building Realtime Web Apps with Angular and Meteor by Michael Redlich
Building Realtime Web Apps with Angular and MeteorBuilding Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and Meteor
Michael Redlich319 views
Java Advanced Features (TCF 2014) by Michael Redlich
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)
Michael Redlich754 views
Introduction to Object-Oriented Programming & Design Principles (TCF 2014) by Michael Redlich
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Michael Redlich2.4K views
Getting Started with Meteor (TCF ITPC 2014) by Michael Redlich
Getting Started with Meteor (TCF ITPC 2014)Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)
Michael Redlich902 views
Getting Started with Java (TCF 2014) by Michael Redlich
Getting Started with Java (TCF 2014)Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)
Michael Redlich777 views
C++ Advanced Features (TCF 2014) by Michael Redlich
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)
Michael Redlich1.4K views

Recently uploaded

Five Things You SHOULD Know About Postman by
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About PostmanPostman
40 views43 slides
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...ShapeBlue
83 views15 slides
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueShapeBlue
131 views23 slides
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueShapeBlue
96 views7 slides
Uni Systems for Power Platform.pptx by
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
58 views21 slides
DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
62 views21 slides

Recently uploaded(20)

Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman40 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue83 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue131 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue96 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue62 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue111 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc77 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue50 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue65 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T by ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue56 views
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates by ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue119 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue46 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... by ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue82 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue85 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro29 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue88 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely56 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院

Getting Started with MongoDB

  • 1. Getting Started with MongoDB Capital District Java Developers Network January 16, 2014 Michael P. Redlich @mpredli about.me/mpredli/ 1 Friday, January 17, 14 1
  • 2. Who’s Mike? • BS in CS from Rutgers University • “Petrochemical Research Organization” • Ai-Logix, Inc. (now AudioCodes) • Amateur Computer Group of New Jersey • Publications • Presentations 2 Friday, January 17, 14 2
  • 3. Upcoming Events • Trenton Computer Festival • March 14-15, 2014 • tcf-nj.org • Emerging Technologies for the Enterprise • April 22-23, 2014 • phillyemergingtech.com 3 Friday, January 17, 14 3
  • 5. Objectives • What is MongoDB? • What is NoSQL? • Getting Started with MongoDB • Basic CRUD Operations • Live Demos (yea!) • MongoDB Resources 5 Friday, January 17, 14 5
  • 6. What is MongoDB? (1) • “...an open-source document database that provides high performance, high availability, and automatic scaling.” MongoDB Web Site, http://www.mongodb.org/ • It’s name derived from “humongous” • Written in C++ 6 Friday, January 17, 14 6
  • 7. What is MongoDB? (2) • “...an open-source database used by companies of all sizes, across all industries and for a wide variety of applications. It is an agile database that allows schemas to change quickly as applications evolve, while still providing functionality developers expect from traditional databases...” MongoDB Products Web Site, http://www.mongodb.com/products/mongodb/ 7 Friday, January 17, 14 7
  • 8. What is NoSQL? • Developed to address shortcomings of a traditional SQL relational database, namely: • big data • frequency of access to big data • performance and scalability 8 Friday, January 17, 14 8
  • 10. Who is Using MongoDB? 10 Friday, January 17, 14 10
  • 11. Features of MongoDB • • • • • Document-Oriented Storage • • Full Index Support • • Auto-Sharding Replication and High Availability Fast In-Place Updates Map/Reduce GridFS Professional Support by MongoDB Querying 11 Friday, January 17, 14 11
  • 14. What is a Document? • Basic unit of data • analogous to a row in a RDBMS • An ordered set of fields (keys) with associated values stored in BSON format • similar to JSON 14 Friday, January 17, 14 14
  • 15. What is BSON? • “...a binary-encoded serialization of JSON-like documents.” BSON Web Site, http://www.bsonspec.org/ • Binary JSON • Designed to be lightweight, traversable, and efficient 15 Friday, January 17, 14 15
  • 16. What is a Collection? • A group of documents • analogous to a table in a RDBMS • Schema-less 16 Friday, January 17, 14 16
  • 17. Advantages of Documents • Documents correspond to native data types in many programming languages • Embedded documents and arrays reduce the need for expensive joins • Dynamic schema support fluent polymorphism 17 Friday, January 17, 14 17
  • 18. Document Structure { embedded document lastName : “Redlich”, firstName : “Michael”, email : “mike@redlich.net” role : { officer : “President”, field sig : “Java Users Group” value } } 18 Friday, January 17, 14 18
  • 19. Field Names • Strings • Cannot contain: • null • dots (.) • dollar sign ($) • No duplicate field names 19 Friday, January 17, 14 19
  • 20. Conventions • Command Prompt ($) • MySQL prompt (mysql>) • MongoDB prompt (>) • Keywords (db, find(), etc.) • Variables (variable) 20 Friday, January 17, 14 20
  • 21. Example Database • ACGNJ Board of Directors: • lastName • firstName • roles (embedded documents) • tenure 21 Friday, January 17, 14 21
  • 22. Getting Started • Download MongoDB • Create a default data directory •/data/db •C:datadb • Create your first MongoDB database 22 Friday, January 17, 14 22
  • 23. Starting MongoDB • Start an instance of the MongoDB server: $ mongod • Start an instance of the MongoDB client (a JavaScript-based shell): $ mongo 23 Friday, January 17, 14 23
  • 24. Mongo Shell (1) • Show the list of shell commands: > help • Show the list of databases: > show dbs • Show the current database: > db 24 Friday, January 17, 14 24
  • 25. Mongo Shell (2) • Specify the database to use or create: > use database • Show the collections within the current database: > show collections • Show the users within the database: > show users 25 Friday, January 17, 14 25
  • 26. Mongo Shell (3) • Show the recent system.profile entries: > show profile • Tab completion • Command history 26 Friday, January 17, 14 26
  • 27. Primary Key • Denoted by a special field, _id • It can be generated: • Implicitly: {_id : ObjectID(value)} • • Explicitly: • {_id : 2 }, { _id : “MPR”} 27 Friday, January 17, 14 27
  • 28. ObjectIDs • Default type for _id • A 12-byte hexadecimal BSON type: 28 Friday, January 17, 14 28
  • 31. Create a Database • Create a database in MySQL: mysql> CREATE DATABASE database; • Create a database in MongoDB: > use database 31 Friday, January 17, 14 31
  • 32. Create a Collection • Create a new table in MySQL: mysql> CREATE TABLE table(column datatype,...); • Create a new collection in MongoDB: > db.collection.insert({field:value,. ..}) 32 Friday, January 17, 14 32
  • 33. Insert Data • Insert a row in MySQL: > INSERT INTO table(column,...) VALUES(value,...); • Insert a document in MongoDB: > db.collection.insert({field:value,. ..}) 33 Friday, January 17, 14 33
  • 34. Insert Data with Loops • Insert multiple documents with an array: > for(int i = 0;i < j;++i) db.collection.insert({field:array[i ]}); • Insert multiple documents with variable: > for(int i = 0;i < j;++i) db.collection.insert({field:i}) 34 Friday, January 17, 14 34
  • 37. Query (1) • Retrieve all rows in MySQL: mysql> SELECT * FROM table; • Retrieve all documents in MongoDB: > db.collection.find() 37 Friday, January 17, 14 37
  • 38. Query (2) • Retrieve specified columns in MySQL: mysql> SELECT column1,column2 FROM table; • Retrieve specified fields in MongoDB: > db.collection.find({}, {field1:true,field2:true}) 38 Friday, January 17, 14 38
  • 39. Query (3) • Retrieve specific rows in MySQL: mysql> SELECT * FROM table WHERE column = value; • Retrieve specific documents in MongoDB: > db.collection.find({field:value}) 39 Friday, January 17, 14 39
  • 40. Query (4) • Retrieve specific rows in MySQL: mysql> SELECT * FROM table WHERE column = value ORDER BY value ASC; • Retrieve specific documents in MongoDB: > db.collection.find({field:value}).s ort({field:1}) 40 Friday, January 17, 14 40
  • 41. Query (5) • Query for multiple documents (returns a cursor): > db.collection.find() • Query for one document (returns a single document): > db.collection.findOne() 41 Friday, January 17, 14 41
  • 42. Query Selectors • Scalar: • $ne, $mod, $exists, $type, $lt, $lte, $gt, $gte • Vector: • $in, $nin, $all, $size 42 Friday, January 17, 14 42
  • 43. Query (6) • Retrieve specific rows in MySQL: mysql> SELECT * FROM table WHERE column != value; • Retrieve specific documents in MongoDB: > db.collection.find({field: {$ne:value}}) 43 Friday, January 17, 14 43
  • 44. Query (7) • Retrieve specific rows in MySQL: mysql> SELECT * FROM table WHERE column1 = value OR column2 = value; • Retrieve specific documents in MongoDB: > db.collection.find({$or: [{field:value},{field:value}]) 44 Friday, January 17, 14 44
  • 45. Query (8) > db.members.aggregate({$project: {officer:"$roles.officer"}}) > db.members.find({tenure: {$gt:ISODate("2014-12-31")}}) > db.members.find({"roles.officer": {$exists:true}}).sort({"roles.offic er":1}) 45 Friday, January 17, 14 45
  • 49. Update (1) • Update a row in MySQL: mysql> UPDATE table SET column = value WHERE id = id; • Update a document in a MongoDB: > db.collection.update({_id:value}, {$set:{field:value}},{multi:true}) 49 Friday, January 17, 14 49
  • 50. Update (2) • Update a row in MySQL: mysql> UPDATE table SET column1 = value WHERE column2 > value; • Update a document in MongoDB: > db.collection.update({field1: {$gt:value}},{$set:{field2:value}}, {multi:true}) 50 Friday, January 17, 14 50
  • 51. Update (3) • Update a document using findOne(): > redlich = db.members.findOne({lastName: "Redlich"}) > redlich.roles = [{sig:"Java Users Group"}] > db.members.update({lastName: "Redlich"},redlich) 51 Friday, January 17, 14 51
  • 52. Atomic Update Operators • Scalar: • $inc, $set, $unset • Vector: • $push, $pop, $pull, $pushAll, $pullAll, $addToSet 52 Friday, January 17, 14 52
  • 53. Update (4) > db.members.update({lastName: "Redlich"},{$set: {"ISODate("2016-12-31")}}) > db.members.update({"roles.sig"}, {$set:{"roles.sig":"JUG"}}) 53 Friday, January 17, 14 53
  • 55. Delete (1) • Delete all rows in MySQL: mysql> DELETE FROM table; • Delete all documents in MongoDB: > db.collection.remove() 55 Friday, January 17, 14 55
  • 56. Delete (2) • Delete specific rows in MySQL: mysql> DELETE FROM table WHERE column = value; • Delete specific documents in MongoDB: > db.collection.remove({field:value}) 56 Friday, January 17, 14 56
  • 57. Delete (2) • Delete a MySQL database mysql> DROP DATABASE database; • Delete a MongoDB database > use database > db.dropDatabase() 57 Friday, January 17, 14 57
  • 59. Export (1) • Export a collection to a JSON file • Ensure mongod is running $ mongoexport --db database -collection collection --out path/ filename.json 59 Friday, January 17, 14 59
  • 60. Export (2) • Export a collection to a CSV file • Ensure mongod is running • A list of fields is required $ mongoexport --db database -collection collection --fields field1,field2,... --csv --out path/ filename.json 60 Friday, January 17, 14 60
  • 61. Import • Import a collection from a JSON, CSV, or TSV file • Ensure mongod is running $ mongoimport --db database -collection collection < path/ filename.json 61 Friday, January 17, 14 61
  • 62. Dump • Dump a specified MySQL database: $ mysqldump -u root --opt database > path.filename.sql • Dump all MongoDB databases: • Ensure mongod is not running $ mongodump --dbpath /data/db --out path 62 Friday, January 17, 14 62
  • 64. Package Components (1) • Core Processes • mongod - core DB process • mongos - controller & query router (sharding) • mongo - interactive JavaScript-based shell 64 Friday, January 17, 14 64
  • 65. Package Components (2) • Binary Import and Export • mongodump - creates BSON dump files • mongorestore - restores BSON dump files • bsondump - converts BSON to JSON • mongooplog - streams oplog entries 65 Friday, January 17, 14 65
  • 66. Package Components (3) • Data Import and Export • mongoimport - imports JSON, CSV, or TSV data formats • mongoexport - exports to JSON, CSV, or TSV data formats 66 Friday, January 17, 14 66
  • 67. Package Components (4) • Diagnostic Tools • mongostat - captures database operations by type (insert, query, etc.) • mongotop - tracks read/write activity • mongosniff - provides tracing/sniffing view into database activity • mongoperf - performance testing tool 67 Friday, January 17, 14 67
  • 68. Package Components (5) • GridFS • mongofiles - provides a commandline interaction to a GridFS storage system 68 Friday, January 17, 14 68
  • 70. MongoDB Resources (2) • mongodb.org • docs.mongodb.org • mongodb.org/books • mongodb.com/products/mongodb • mongodb.com/reference • bsonspec.org • education.mongodb.com 70 Friday, January 17, 14 70