You are on page 1of 12

Sheet1

LECTURE
WEEK 1: INTRODUCTION
Welcome to the class
Introduction to M101N
What is MongoDB?
MongoDB Relative to Relational
Application Architecture
Quick Introduction to the Mongo Shell
Introduction to JSON
Installing MongoDB (windows)
MongoDB is Schemaless
JSON Revisited
JSON Spec
Introduction to Our Class Project, the Blog
Blog in Relational Tables
Blog in Documents
Introduction to Schema Design
H1.1
WEEK 2: CRUD

https://youtu.be/B_MBXbP9LSE
https://youtu.be/hVcGEb7HiDc
https://youtu.be/Lfl8hdQOi6Y
https://youtu.be/-KIC1LXxcGM
https://youtu.be/RDEhRO_FwGE
https://youtu.be/e18vCIdQKp4
https://youtu.be/PTATjNSjbJ0
https://youtu.be/sBdaRlgb4N8
https://youtu.be/uKB-Hoqs6zI
https://youtu.be/CTffxoSSLqg
https://youtu.be/kOrsT94-A28
https://youtu.be/NTDgDqgs9gk
https://youtu.be/kqglm5c52oI
https://youtu.be/JFkBoIxjLqo
https://youtu.be/6XE3wZCPiZ8
https://youtu.be/TV7RWf6DBbc

Introduction to Week 2
https://youtu.be/H_OcFFkRYX0
CRUD and the Mongo Shell
https://youtu.be/C7LinMC2o5o
Secrets of the Mongo Shell
https://youtu.be/IIIzjPp-IRE
BSON Introduced
https://youtu.be/K3J6WvDW-Hc
Inserting Docs
https://youtu.be/qqfVxGLIrLg
Introduction to findOne
https://youtu.be/w9V0fJsDwbQ
Introduction to find
https://youtu.be/8kKfFK6a0Ak
Querying Using field Selection
https://youtu.be/UIg86QjSoyY
Querying Using $gt and $lt
https://youtu.be/FHLrz4VGzkg
Inequalities on Strings
https://youtu.be/imCCKOevU3c
Using regexes, $exists, $type
https://youtu.be/lI-jhqYf1JY
Using $or
https://youtu.be/BW5ElNCRZps
Using $and
https://youtu.be/hYk7pjgjjzc
Querying Inside Arrays
https://youtu.be/jvEqwW75Bus
Using $in and $all
https://youtu.be/QU2NrkviORE
Queries with Dot Notation
https://youtu.be/NrjFECIfwqk
Querying, Cursors
https://youtu.be/3jA6iFSEJOI When can you change the behavior of a c
Counting Results
https://youtu.be/eKD5bVmNQMI
Wholesale Updating of a Document
https://youtu.be/g7Fi1xXsuvU
Using the $set Command
https://youtu.be/XyhNjs2pNVc
Using the $unset Command
https://youtu.be/LpErz8jLW0I
Using $push, $pop, $pull, $pushAll, $pullAll, $addToSet
https://youtu.be/GOn0EWKDQoY
Upserts
https://youtu.be/Dy2p8k3EZs4
Multi-update
https://youtu.be/2GNNdUmDL-4
Removing Data
https://youtu.be/5K0t1dU8IJY
getLastError (MongoDB v2.4 and earlier)
https://youtu.be/a6o0TQjUMug
Getting Started with the .NET Driver
https://youtu.be/ujuCwFiqfpA
.NET driver, MongoClient, MongoDatabase, MongoCollectionhttps://youtu.be/3xaIrMiGzT0
.NET driver, document representation
https://youtu.be/-cOlCv2ptCA
.NET Driver, Poco Representation
https://youtu.be/wYHn8sqBMuI
.NET Driver, InsertOne
https://youtu.be/k3J1tLnJSqc
.NET Driver, Find
https://youtu.be/vgAmMCxzmzo Which method name is NOT a way to

Page 1

Sheet1
.NET Driver, Find with Filters
.NET Driver, Find with Skip, Limit and Sort
.NET Driver, Find with Projections
.NET Driver, UpdateOne and UpdateMany
.NET Driver, DeleteOne and DeleteMany
.NET Driver, FindOneAndUpdate, FindOneAndReplace, Fin
.NET driver, BulkWrite
WEEK 3: SCHEMA DESIGN
Introduction to Week 3
MongoDB Schema Design
Relational Normalization
Mongo Design for Blog
Alternative Schema for Blog
Living Without Constraints
Living Without Transactions
One to One Relations
One to Many Relations
Many to Many Relations
Multikeys
Benefits of Embedding
Trees
When to Denormalize
WEEK 4: PERFORMANCE
Introduction to Week 4
Storage Engines: Introduction
Storage Engines: MMAPv1
Storage Engines: WiredTiger
Indexes
Creating Indexes
Discovering (and Deleting) Indexes
Multikey Indexes
Dot Notation and Multikey
Index Creation Option, Unique
Index Creation, Sparse
Index Creation, Background
Using Explain
Explain: Verbosity
Covered Queries
When is an Index Used?
How Large is Your Index?
Number of Index Entries
Geospatial Indexes
Geospatial Spherical
Text Indexes
Efficiency of Index Use
Efficiency of Index Use Example
Logging Slow Queries
Profiling
Mongotop

https://youtu.be/yEiIBTMrN7E
https://youtu.be/vvm1RX85yqo
https://youtu.be/pZTlQgPSi_M
https://youtu.be/XpHsKDcWlrM
https://youtu.be/dDo891eZfe0
https://youtu.be/o0d6vYZLhqI
https://youtu.be/Q2na8Ks_sLM
Homework 2.1
Homework 2.2
Homework 2.3
https://youtu.be/9urnY4OcuNM
https://youtu.be/AABYJM12qF4
https://youtu.be/GX__f2s4hd8
https://youtu.be/PRylEHH5t84
https://youtu.be/ZvqNWVWB2-o
https://youtu.be/YFRMkDPaams
https://youtu.be/FfRr3qjRfww
https://youtu.be/cCsfon0vUlQ
https://youtu.be/EIaP1KbVkUc
https://youtu.be/fEYYjZ7zEHc
https://youtu.be/KtIY4Q1tUao
https://youtu.be/XIN0Dqht08Q
https://youtu.be/lIjXyQklGWY
https://youtu.be/jDZ-HFoJ0vg
Homework 3.1
Homework 3.2
Homework 3.3
https://youtu.be/GGMfM3pYK_4
https://youtu.be/YvK7I9fYpK4
https://youtu.be/os3591KviNM
https://youtu.be/aNsugW7r3mM
https://youtu.be/U3iWPF5jP-g
https://youtu.be/xi2gtzZez6Q
https://youtu.be/dX49IcmTrGA
https://youtu.be/_NGwn_X82Dw
https://youtu.be/wT0_ktAZbBg
https://youtu.be/D-Ra5TEaaL4
https://youtu.be/ZznHByqtTMA
https://youtu.be/AchmKNj2qhw
https://youtu.be/r5YeICVzDjQ
https://youtu.be/WxXVun6bZ20
https://youtu.be/QyV79jsSJ9Y
https://youtu.be/JyQlxDc549c
https://youtu.be/wjA0eo_lihg
https://youtu.be/xiujksUfzUA
https://youtu.be/UKUDYqNVL6I
https://youtu.be/pULU4DVsUWQ
https://youtu.be/nLau5Fx9LC8
https://youtu.be/JJmIf0pn100
https://youtu.be/g032EW67SRA
https://youtu.be/aWuvC-O7Qkk
https://youtu.be/pN1Yhrup9-I
https://youtu.be/D9YLXgy7NYo

Page 2

Sheet1
Mongostat
Sharding Overview
Homework 4.1
Homework 4.2
Homework 4.3
Homework 4.4

https://youtu.be/E2aDTSes3Wc
https://youtu.be/BDxT-VZdYqc
db.products.find( { 'brand' :
"GE"
} ).sort(
{ price251120
:1})
The query
examines
documents.
The problem you'll notice is the
db.profile.find({ns: "school2.students" }

WEEK 5: AGGREGATION FRAMEWORK


Introduction to Week 5
Simple Aggregation Example
The Aggregation Pipeline
Simple Example Expanded
Compound Grouping
Using a document for _id
Aggregation Expressions
Using $sum
Using $avg
Using $addToSet
Using $push
Using $max and $min
Double $group stages
Using $project
Using $match
Using $sort
Using $limit and $skip
Revisiting $first and $last
Using $unwind
$unwind example
Double $unwind
Mapping between SQL and Aggregation
Some Common SQL examples
Limitations of the Aggregation Framework
Aggregation in .NET

https://youtu.be/EaEIHm3CMQM
https://youtu.be/DQBXCsjeO5c
https://youtu.be/AuO8CEkTG6Y
https://youtu.be/3lEpnMcfpCs
https://youtu.be/qTbtax_cKcc
https://youtu.be/zoN4cj_XQzY
https://youtu.be/L4G14MTfTgQ
https://youtu.be/93MSz3uDC1A
https://youtu.be/baIDZ-M5j7w
https://youtu.be/YzURaZnKI9s
https://youtu.be/LQcBM-g0ACY
https://youtu.be/BYoNX4trjOQ
https://youtu.be/EIWF9Oxeb8M
https://youtu.be/TbQ2PI5Fib0
https://youtu.be/7RtHG90Hrbw
https://youtu.be/HUEtV7omSb8
https://youtu.be/o5hzYKXUyrU
https://youtu.be/JOdAnxVAMwc
https://youtu.be/E4aYOQPeQvI
https://youtu.be/U_4Enh2TTp4
https://youtu.be/YXGL27217B8
https://youtu.be/auL2R0XKlyM
https://youtu.be/ep2gLSR6C0U
https://youtu.be/U_gRSxEq3c0
https://youtu.be/Lyysv6LpHDw

WEEK 6: APPLICATION ENGINEERING


Introduction to Week 6
Write Concern
Network Errors
Introduction to Replication
Replica Set Elections
Write Consistency
Creating a Replica Set
Replica Set Internals
Failover and Rollback
Connecting to a Replica Set from .NET Driver
Bad Things Happen to Good Nodes
Write Concern Revisited
Read Preferences
Review of Implications of Replication
Introduction to Sharding
Building a Sharded Environment

https://youtu.be/BmQuvmpt_ZQ
https://youtu.be/oRDYNWCYnGo
https://youtu.be/xWNzCkTCN-M
https://youtu.be/f1WTYGORU3w
https://youtu.be/WFXSVHO78bQ
https://youtu.be/Oqf_Eza-s1M
https://youtu.be/flCFVFBRsKI
https://youtu.be/6GbrJmxCEl0
https://youtu.be/IW1oW_Adlt0
https://youtu.be/pli6Gsi7Z-k
https://youtu.be/7ZYqrmGOlpc
https://youtu.be/5VyXyccjS3k
https://youtu.be/mhHaS4ZWzZE
https://youtu.be/K5ISnvYKQFQ
https://youtu.be/_GfDqa1qRl0
https://youtu.be/dn45G2yw20A

Page 3

Sheet1
Implications of Sharding
Sharding + Replication
Choosing a Shard Key

https://youtu.be/ig278F60gRA
https://youtu.be/gkUCUbM0oEg
https://youtu.be/8q2GB3QSBSI

WEEK 7: CASE STUDIES


Introduction to Week 7
Interview with Charity Majors, Parse
Interview with Ryan Bubinski, Codecademy

https://youtu.be/eL054c6nkaY
https://youtu.be/PTp0A8_IVAY
https://youtu.be/RkPmVQNesZA

FINAL EXAM

Page 4

Sheet1
ANSWER

Homework & Final Exam


https://youtu.be/CAR42sMkXEo
https://youtu.be/IAvnMgvHuLw
https://youtu.be/YQTqdLe3W4M
https://youtu.be/uWcOsdV4Iz4

{"fruit":["apple", "pear", "peach"]}

5
1
https://youtu.be/wiwOEG_6ojs
https://youtu.be/pLW6hX-hvAA
{ "title" : "Star Wars",
-1030
https://youtu.be/nWOt4VN6Y3g
https://youtu.be/a6TFwpCoLoY
https://youtu.be/4hsTQrMs-xY
https://youtu.be/BRAVnBz3ogE
https://youtu.be/uN_wf5a3BE4
https://youtu.be/ouHFZgtEAuU
https://youtu.be/ouHFZgtEAuU
https://youtu.be/tY7I1l8JdDI
https://youtu.be/ZRWT0lcHsoU
https://youtu.be/yMi7PwOoqXY
https://youtu.be/diimYkvr374
https://youtu.be/oIkSajy8NLw
https://youtu.be/gwECaa4N9Xc
https://youtu.be/6O1UGHwuEww
https://youtu.be/yiEjK_V008s
This can be done at any point before the
first document is called and before you've
checked to see if it is empty.
https://youtu.be/Uozp0diXOc8
https://youtu.be/pwnRUdtI8lY
https://youtu.be/G2e5ZxqR6nw
https://youtu.be/-CzLvQS12wY
https://youtu.be/bGbiIGEM0FY
https://youtu.be/Loo5XKQAryM
https://youtu.be/puGW4t5wmOU
https://youtu.be/AGvJs8xqZJg

MongoDB.Driver
doc.Add(field, value);

42
{}

db.scores.find({type: "essay", score: 50},{_id:false, student:true})

2
db.users.find({name : {$regex : "q"}, email:{$exists:true}})
db.scores.find({$or:[{score:{$lt:50}},{score:{$gt:90}}]})

db.scores.count({type:"essay", score:{$gt:90}})
db.users.update({'username': 'splunker'}, {'$set':
{'country': 'RU'}})

doc[field] = value;

ToArrayAsync

Page 5

Sheet1

https://youtu.be/Wfsll8tt_ng
54

22

https://youtu.be/OVDnLJXpqNE
https://youtu.be/s5E0T4caqj4
https://youtu.be/3VckBMGInic
https://youtu.be/189zABW3HHk
https://youtu.be/BjW64RkzlGg
https://youtu.be/KQcspnr-Y2M

https://youtu.be/80P6yVSkKQY

https://youtu.be/SR76BjJl-PQ
This is the basic idea behind why we
call it MMAPv1.
https://youtu.be/dmnPb-hhVHM
https://youtu.be/5Z6V8mJ8eS4
https://youtu.be/9FUOetT45AM
https://youtu.be/caSP0dO02iU

https://youtu.be/ia6dzcj-ZMk
https://youtu.be/yV_KEDEzOyc
x
https://docs.mongodb.org/manual/core/index-creation/?_ga=1.173842341.745792798.1450433650#index-creation-background
https://youtu.be/Gpj_s49H_rQ
https://youtu.be/qBFFnnoK1NA
https://youtu.be/MxHsmUXjkKo
db.foo.find( { a : 3 } ) & db.foo.find( { c
: 1 } ).sort( { a : 1, b : 1 } )
https://youtu.be/mXHUIghDkFw
https://youtu.be/4UW_oMSswTo
db.places.find({location:{$near:[74,140]}}).limit(3)
https://youtu.be/hVLa0H7Oe98
db.stores.find({
loc:{ $near: { $geometry:
https://youtu.be/YtRnCyKS1VE
{ type: "Point", coordinates: [-130, 39]},
$maxDistance:1000000 } } })
https://youtu.be/7OK0e1gftjg
complete
the result set, without the need https://docs.mongodb.org/manual/reference/operator/query/regex/?_ga=1.188480174.74579
to
scan
a
substantially
larger
number
of
Equality fields before range fields Sort
index before
keys (orrange
documents)
in orderfields
to
fields
fields Equality
before
sort
fields
db.system.profile.find({millis:
https://youtu.be/A4x4kE02pSc
{$gt:1000}}).sort({ts:-1})
-

Page 6

Sheet1

The getmore column concerns the number of


https://youtu.be/etOEgMTFKW0
requests per time interval to get additional data
db.products.find( { $and : [ { price : { $gt from a cursor
: 30 } },{ price : { $lt :
The
uses an
index to
the
50 } query
} ] } ).sort(
{ brand
: 1determine
})
order
in which to return result documents.
'db.posts.explain("executionStats").find({
"Tags" : "asd"}).sort({"CreatedAtUtc":15820

https://youtu.be/Nt0cQI86G40
https://youtu.be/mcnGfI69rRc
https://youtu.be/nr1E1qTyIHU
https://youtu.be/bIlwnlYBRA0

db.products.aggregate([{$group: {"_id": "$category", "num_products":{"$sum":1}}}])


nu Transpose
3
5

https://youtu.be/kJ0k2na4ukU
https://youtu.be/ATO_s_Ah08o
https://youtu.be/tT6Jx8s9dTc
https://youtu.be/zGcTxUQuLGE
https://youtu.be/hFqDvVXtm6E
https://youtu.be/sHCdOiCispA
https://youtu.be/J-asAAEHJ0Q
https://youtu.be/IGN0lXg-kJ0
https://youtu.be/CHGiumXE-pU
https://youtu.be/-cghyd6AHHA
https://youtu.be/joRw-fqCIWA
https://youtu.be/MVSoinykIJA
https://youtu.be/Xfl3m7wz8ts
https://youtu.be/jAWL-BJD0tI
https://youtu.be/pziFq1oVRI4

$first, $last
db.zips.aggregate([{"$group":{"_id":"$state", "population":{$sum:"$pop"}}}])
db.zips.aggregate([{"$group":{"_id":"$state", "average":{$avg:"$pop"}}}])
db.zips.aggregate([{"$group":{"_id":"$city", "postal_codes":{"$addToSet":"$_id"}}}])
Same result
db.zips.aggregate([{$group:{"_id":"$state", pop:{$max:"$pop"}}}])
52 and 22
db.zips.aggregate([{$project:{_id:0, city:{$toLower:"$city"}, pop:1, state:1, zip:"$_id"}}])
db.zips.aggregate([{$match:{pop:{$gt:100000}}}])
db.zips.aggregate([{$sort:{state:1, city:1}}])
0
54
6
$push
$push operator?

https://youtu.be/6b5-Eg-vNMY
https://youtu.be/xrruRJHSpzc
https://youtu.be/XCssKzhlnZU
https://youtu.be/vrUxTTD-XwA
https://youtu.be/SjaJEYK1u3E
https://youtu.be/ibZVf59aUj8
https://youtu.be/kGDhzwLZmXU
https://youtu.be/t3rNxRg6WZE

https://youtu.be/hQrCwRplszo
https://youtu.be/wWG5GUt76lw
https://youtu.be/8wuWShep8Qs
https://youtu.be/hy1MDmvRElQ

Page 7

Sheet1
https://youtu.be/vfl0hqdgB3Q
https://youtu.be/hnuiYokdO7g
https://youtu.be/91tO_iGga5w

Page 8

Sheet1

{ "a" : 1, "b" : { "b" : 1

e: 50},{_id:false, student:true})

"}, email:{$exists:true}})
}},{score:{$gt:90}}]})

Page 9

Sheet1

4,140]}}).limit(3)
All 3

Page 10

Sheet1
the faults column appears only in the mmapv1
output

: {"_id": "$category", "num_products":{"$sum":1}}}])

d":"$state", "population":{$sum:"$pop"}}}])
_id":"$state", "average":{$avg:"$pop"}}}])
d":"$city", "postal_codes":{"$addToSet":"$_id"}}}])

"$state", pop:{$max:"$pop"}}}])

0, city:{$toLower:"$city"}, pop:1, state:1, zip:"$_id"}}])


$gt:100000}}}])

Yes

Page 11

Sheet1

Page 12

You might also like