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
Nick Jackson
May 07, 2012
Technology
1
100
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
67
Development Tools
jacksonj04
0
82
Eating Your Own Dog Food
jacksonj04
0
310
LNCD and The Cloud
jacksonj04
0
110
OAuth 101
jacksonj04
3
350
API Driven Development
jacksonj04
0
200
We Can Haz Ur Datas?!
jacksonj04
0
310
Universal Search at Lincoln
jacksonj04
0
35
Jerome Overview
jacksonj04
0
38
Other Decks in Technology
See All in Technology
「スニダン」開発組織の構造に込めた意図 ~組織作りはパッションや政治ではない!~
rinchsan
3
570
EMとして2023年度に頑張ったこと / What we did well in FY2023 as a EM
pauli
1
170
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
1
250
現代CSSフレームワークの内部実装とその仕組み
poteboy
8
3.7k
アクセス制御にまつわる改善 / Improving access control
itkq
0
560
複雑な構成要素を持つUIとの向き合い方 〜新・支出グラフでの実例〜 / B43 TECH TALK
nakamuuu
0
140
KubeConにproposalを送りたい人へのアドバイス
sat
PRO
3
260
MLOpsの「壁」を乗り越える、LINEヤフーの Data Quality as Code
lycorptech_jp
PRO
5
550
エンジニア候補者向け資料2024.04.24.pdf
macloud
0
3.3k
20分で完全に理解するGrafanaダッシュボード
hamadakoji
3
740
TechFeed Experts Night#27 〜 フロントエンドフレームワーク最前線 (Svelte)
baseballyama
1
540
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
830
Featured
See All Featured
Designing on Purpose - Digital PM Summit 2013
jponch
110
6.5k
What's new in Ruby 2.0
geeforr
337
31k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
104
6.6k
In The Pink: A Labor of Love
frogandcode
138
21k
Documentation Writing (for coders)
carmenintech
60
3.9k
Designing for Performance
lara
601
67k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
GitHub's CSS Performance
jonrohan
1025
450k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
125
32k
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