Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MongoDB 101
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Nick Jackson
May 07, 2012
Technology
1
120
MongoDB 101
A crash course on MongoDB I gave to attendees at the JISC MRD Hackday organised by DevCSI.
Nick Jackson
May 07, 2012
Tweet
Share
More Decks by Nick Jackson
See All by Nick Jackson
It's all about the data.
jacksonj04
0
82
Development Tools
jacksonj04
0
98
Eating Your Own Dog Food
jacksonj04
0
340
LNCD and The Cloud
jacksonj04
0
120
OAuth 101
jacksonj04
3
370
API Driven Development
jacksonj04
0
220
We Can Haz Ur Datas?!
jacksonj04
0
350
Universal Search at Lincoln
jacksonj04
0
48
Jerome Overview
jacksonj04
0
50
Other Decks in Technology
See All in Technology
KubeCon + CloudNativeCon NA ‘25 Recap, Extensibility: Gateway API / NRI
ladicle
0
160
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
4
660
Claude Codeベストプラクティスまとめ
minorun365
57
32k
Introduction to Bill One Development Engineer
sansan33
PRO
0
350
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
66k
AI時代、1年目エンジニアの悩み
jin4
1
130
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
100
新規事業における「一部だけどコア」な AI精度改善の優先順位づけ
zerebom
0
450
Vitest Highlights in Angular
rainerhahnekamp
0
120
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
We Built for Predictability; The Workloads Didn’t Care
stahnma
0
110
データ民主化のための LLM 活用状況と課題紹介(IVRy の場合)
wxyzzz
2
310
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
How to Talk to Developers About Accessibility
jct
2
120
How to train your dragon (web standard)
notwaldorf
97
6.5k
Designing for Timeless Needs
cassininazir
0
120
Odyssey Design
rkendrick25
PRO
1
480
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2k
The Cult of Friendly URLs
andyhume
79
6.8k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
62
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
110
Docker and Python
trallard
47
3.7k
Transcript
MongoDB 101
I am... • Nick Jackson • Awesome Developer Dude •
University of Lincoln • @jacksonj04
MongoDB Is... • A NoSQL document database.
Eh?
NoSQL • Is not a specification (unlike SQL). • (Generally)
doesn’t have schemas. • (Generally) works at web-scale. • (Generally) doesn’t do relational integrity.
Document Databases • Store documents. • Don’t store key-value pairs.
• Make building APIs and stuff really easy.
Ye Olde SQL id name email 1 Nick
[email protected]
2
Joss
[email protected]
Ye Olde SQL id name email office building 1 Nick
... 3107 MHT 2 Joss ... 3015 MHT 3 Harry ... NULL MHT
:-(
Documents: Awesome! { name: ‘Nick’, email: ‘
[email protected]
’, location: { office:
‘3105’, building: ‘MHT’ } }
Documents: Awesome! { name: ‘Harry’, email: ‘
[email protected]
’ }
Documents: Awesome! { name: ‘Joss’, email: ‘
[email protected]
’, location: { office:
‘3105’, building: ‘MHT’ }, likes: { music: [‘Folk’, ‘Hip-Hop’], drink: [‘Coffee’, ‘Ale’] } }
Servers Are Easy
On Its Own Mongo App
Replicated Mongo 1 Mongo 2 Mongo 3 App
Sharded App Router 1 Router 2 Mongo S1 Mongo S2
Mongo S3
http://mongodb.org
Inserts <3 JSON > db.people.save({name:'Nick'}) > db.people.save({name:'Joss'}) > db.people.save({name:'Harry'})
Query Be Simple... > db.people.find() { "_id" : ObjectId("4fa...103"), "name"
: "Nick" } { "_id" : ObjectId("4fa...104"), "name" : "Joss" } { "_id" : ObjectId("4fa...105"), "name" : "Harry" }
Query Be Simple... > db.people.find({name:'Nick'}) { "_id" : ObjectId("4fa...103"), "name"
: "Nick" }
Query Be Quick... > db.people.ensureIndex({name:1})
Updates are easy > db.people.update({name:'Nick'},{name:'Nick',likes: ['coffee']}) > db.people.find({name:'Nick'}) { "_id"
: ObjectId("4fa...103"), "name" : "Nick", "likes" : [ "coffee" ] }
Queries are powerful > db.people.update({name:'Joss'},{name:'Joss',likes: ['coffee','folk music']}) > db.people.find({likes:'coffee'}) {
"_id" : ObjectId("4fa...103"), "name" : "Nick", "likes" : [ "coffee" ] } { "_id" : ObjectId("4fa...104"), "name" : "Joss", "likes" : [ "coffee", "folk music" ] }
Deletes are also easy > db.people.remove({name:'Nick'}) > db.people.find() { "_id"
: ObjectId("4fa...104"), "name" : "Joss", "likes" : [ "coffee", "folk music" ] } { "_id" : ObjectId("4fa...105"), "name" : "Harry" }
Cool Things! • Geospatial indexes. db.places.find({loc:{$near:[-2, 53]}}) • JavaScript in
the Mongo shell. • Map/Reduce operations. • Can be used as a filesystem.
Downsides It has a few
It’s not ACID • Set of atomic operators, but no
things like transactions. • No enforced consistency. At all. • No locking, so updates can collide and be lost. • Disk writes are (usually) deferred, so data can be lost in failures.
It’s not ‘Enterprise’ • Your DBAs will find it new
and scary. • You need to un-learn a lot of the SQL mindset. • It’s not seen as ‘proven’, but this is generally rubbish.
Some MongoDB Users • Craigslist • MTV • SourceForge •
Disney • National Archives • HM Government • The Guardian • New York Times • bit.ly • GitHub • Foursquare • http://lncn.eu/fhx5