24
mongoDB It’s not just about big data 08.09.2011

MongoDB, it's not just about big data

Embed Size (px)

DESCRIPTION

This is a presentation I gave at a NoSQL meetup in San Francisco on 08.09.11.

Citation preview

Page 1: MongoDB, it's not just about big data

mongoDBIt’s not just about big data

08.09.2011

Page 2: MongoDB, it's not just about big data

what is mongoDB?

Page 3: MongoDB, it's not just about big data

“Scalable, open-source, high-performance, document-oriented database” - 10gen

Page 4: MongoDB, it's not just about big data

Storage model

• relational– database– table– row

• mongoDB– database– collection– document / object

Page 5: MongoDB, it's not just about big data

{ _id: 1234, author: { name: “Bob Davis”, email : [email protected] }, post: “In these troubled times I like to …“, date: { $date: “2010-07-12 13:23UTC” }, location: [ -121.2322, 42.1223222 ], rating: 2.2, comments: [ { user: “[email protected]”, upVotes: 22, downVotes: 14,

text: “Great point! I agree” }, { user: “[email protected]”, upVotes: 421, downVotes: 22,

text: “You are a moron” } ]}

Documents (a.k.a. Objects)

Page 6: MongoDB, it's not just about big data

{ _id: 1234, author: { name: “Bob Davis”, email : [email protected] }, post: “In these troubled times I like to …“, date: { $date: “2010-07-12 13:23UTC” }, location: [ -121.2322, 42.1223222 ], rating: 2.2, comments: [ { user: “[email protected]”, upVotes: 22, downVotes: 14,

text: “Great point! I agree” }, { user: “[email protected]”, upVotes: 421, downVotes: 22,

text: “You are a moron” } ], tags: [ “Politics”, “Virginia” ]}

Flexible “Schemas”

Page 7: MongoDB, it's not just about big data

db.posts.find({ author.name: “mike” })

dynamic queries

db.posts.find({ rating: { $gt: 2 }})

db.posts.find({ tags: “Software” })

db.posts.find().sort({date: -1}).limit(10)

Page 8: MongoDB, it's not just about big data

query language

• Predicates– <, <=, >, >=– $all– $exists– $ne– $in– $nin– $nor– $not– $or– $and

• regular expressions

• $where (js exps)• group()• ** no joins **

Page 9: MongoDB, it's not just about big data

db.posts.ensureIndex({ author.name : 1 }

indexes

db.posts.find({ author.name: “mike” })

Page 10: MongoDB, it's not just about big data

geospatial indexing and queries

db.places.ensureIndex( { loc: “2d” } )

db.places.find({ loc: { $near : [50, 50] } }).limit(10)

db.places.find({loc: {$within : {$box : [[40,40],[60,60]]}}})

db.places.find({loc: {$within : {$center : [[40,40],10]}}})

Page 11: MongoDB, it's not just about big data

Comment c = {author: “[email protected]”,

date: new Date(), text: “great post!”}

db.posts.update({_id: post._id}, {$push: {comments: c}})

atomic updates

Page 12: MongoDB, it's not just about big data

atomic updates

• operators– $set– $unset– $inc– $push– $pushAll– $pull– $pullAll– $bit

Page 13: MongoDB, it's not just about big data

aggregation and map/reduce

Page 14: MongoDB, it's not just about big data

Native drivers in almost every language

• Java• Javascript• Python• Ruby• C#• PHP• and more…

Page 15: MongoDB, it's not just about big data

Built for scalability reliability from the ground up

Page 16: MongoDB, it's not just about big data

High performance, fault tolerant clusters made easy

•Replica sets

•Auto-sharding

Page 17: MongoDB, it's not just about big data

But, mongoDB is not just about big data

Page 18: MongoDB, it's not just about big data

Blog Post

Page 19: MongoDB, it's not just about big data

"Object-Relational mapping is the Vietnam of our industry” - Ted Neward

Page 20: MongoDB, it's not just about big data

{ _id: 1234, author: { name: “Bob Davis”, email : [email protected] }, post: “In these troubled times I like to …“, date: { $date: “2010-07-12 13:23UTC” }, location: [ -121.2322, 42.1223222 ], rating: 2.2, comments: [ { user: “[email protected]”, upVotes: 22, downVotes: 14,

text: “Great point! I agree” }, { user: “[email protected]”, upVotes: 421, downVotes: 22,

text: “You are a moron” } ], tags: [ “Politics”, “Virginia” ]}

… vs. this loveliness

Page 21: MongoDB, it's not just about big data

mongoDB is a great general purpose database

Page 22: MongoDB, it's not just about big data

Good uses for MongoDB

• accounts / user profiles• form data• CMS• storing geo-data• application configuration• application logging• …

Page 23: MongoDB, it's not just about big data

Q&A

Page 24: MongoDB, it's not just about big data

More info

• MongoDB / 10Gen– http://mongodb.org– http://10gen.com

• MongoLab– http://mongolab.com– [email protected]