Jumpstart your day with an introduction to MongoDB by building a simple web app with React, Atlas, and Stitch. First, we will cover the foundations of schema design, security, queries and indexing. Then we'll partially refactor an application using the MERN stack to a serverless application using MongoDB Stitch.
3. Why am I here?
About a decade ago, 3 guys with a lot of industry experience got together and thought
“There must be a better way”. A better way to store data, more intuitive, more natural…
- or -
You came for the beard.
6. About Me
I’m a Senior Engineer on the Education team at MongoDB.
I built the course on MongoDB’s Aggregation Framework, as well as using Aggregation in data science workflows
using SKLearn. Currently working on the new generation of developer courses on MongoDB University.
In a previous life, I disarmed bombs for the U.S. Army. The Hurt Locker used a lot of artistic license and
exaggerated circumstances, but captured what life was like pretty well.
8. What is MongoDB?
MongoDB is a cross-platform and open-source document-oriented database general purpose database. As a
document database, MongoDB doesn’t use table-based structure, rather it uses JSON-like documents that have
dynamic schemas which it calls BSON.
Please keep in mind that NoSQL does not mean no relationships!
9. What is MongoDB?
Written in C++, C, Go, and Javascript
Source and binary packages are available for download at mongodb.com/downloads
SSPL License
Ready for deployment in the cloud or on bare metal
10. What is MongoDB?
MongoDB was written to make it simple to store data.
• {"Key": "Value"}
Documents map naturally to common data structures in most popular programming languages
Schemas are dynamic. There’s no need for expensive migrations.
As new data is encountered, just store it. If the shape of data needs to change, then change it.
11. What is MongoDB?
MongoDB is an ecosystem of products, including a database, visual data explorer, platform, and analytics tools to
make it easier than ever to develop your applications.
14. Not just key-
valueMongoDB’s document model is not just a key-value
store.
Rich document composition is possible, and
encouraged.
Store embedded objects, arrays, rich data types, and
more.
{
"title": "The Martian",
"year": 2015,
"runtime": 130,
"released": ISODate("2015-10-
02T00:00:00Z"),
"cast": [
"Kate Mara",
"Matt Damon",
"Jessica Chastain",
"Kristen Wiig"
]
}
19. Query Language
CREATE TABLE movies (
id MEDIUMINT NOT NULL
AUTO_INCREMENT,
title Varchar(30),
year Number,
rating Number,
PRIMARY KEY (id)
)
db.createCollection("movies")
20. Query Language
INSERT INTO movies(title,
year, rating) VALUES ("The
Shawshank Redemption", 10,
1994)
db.movies.insertOne({title:
"The Shawshank Redemption",
year: 1994, rating: 10})
21. Query Language
ALTER TABLE movies ADD cast
ARRAY
UPDATE movies SET cast =
["Morgan Freeman", "Tim
Robbins"] WHERE title = "The
Shawshank Redemption"
db.movies.updateOne(
{title: "The Shawshank
Redemption"},
{$set: { "cast": ["Morgan
Freeman", "Tim Robbins" ] } }
)
22. Query Language
ALTER TABLE movies ADD cast
ARRAY
UPDATE movies SET cast =
["Morgan Freeman", "Tim
Robbins"] WHERE title = "The
Shawshank Redemption"
db.movies.updateOne(
{title: "The Shawshank
Redemption"},
{$set: { "cast": ["Morgan
Freeman", "Tim Robbins" ] } }
)
23. Query Language
SELECT * FROM movies
SELECT * FROM movies WHERE
rating > 7
SELECT * FROM movies WHERE
rating > 7 LIMIT 1
SELECT * FROM movies WHERE
rating > 7 AND year > 1990
??
db.movies.find()
db.movies.find({rating: { $gt:
7 }})
db.movies.findOne({rating: {
$gt: 7 }})
db.movies.find({rating: { $gt:
7 }, year: { $gt: 1990 } })
db.movies.find({cast: "Morgan
Freeman"})
25. Query Language - Performance
Indexes support the efficient execution of queries in MongoDB.
Many index types
• Single Field
• Multikey
• Text
• Geospatial
• Hashed
• Compound
26. Query Language - Aggregation
A framework for data aggregation modeled on the concept of data processing pipelines.
Documents enter a multi-stage pipeline that transforms the documents into aggregated results.
Reduce the CPU cycles in processing your app, let MongoDB handle aggregation.
Results produced from aggregation lower in total byte size of your data, saving bandwidth.
27. Query Language - Aggregation
A framework for data aggregation modeled on the concept of data processing pipelines.
Documents enter a multi-stage pipeline that transforms the documents into aggregated results.
31. Resiliency – The Replica Set
Your application talks to MongoDB through the
driver, which is constantly monitoring your replica
set health.
Internally, the replica set is monitoring health as
well, ready to react in case of emergency.
40. Atlas – So Much More
Monitoring and Alerting
• Supports Third-Party integration
• Webhooks
• Email
• SMS
• PagerDuty
• Slack
Live Migration
Backups and Recovery
BI Connector