KEMBAR78
Intro to mongodb mongouk jun2010 | PPTX
Twitter:  #mongoukIntro to MongoDBMongoUKDwight Merriman, 10gen
Non-relationalOperational Stores(“NoSQL”)RDBMS(Oracle, MySQL)New Gen. OLAP(vertica, aster, greenplum)
NoSQL Really Means:non-relational, next-generation operational datastores and databases
no joins+no complex transactionsHorizontally ScalableArchitectures
no joins+no complex transactionsNew Data Models
New Data Modelsimproved ways to develop applications?
Data ModelsKey / Valuememcached, DynamoTabularBigTableDocument OrientedMongoDB, CouchDB, JSON stores
Focus on performancememcached
key/valuescalability & performanceRDBMSdepth of functionality
JSON-style Documentsrepresented as BSON{“hello”:“world”}\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00http://bsonspec.org
Flexible “Schemas”{“author”: “eliot”, “text”: “...”,“tags”: [“mongodb”]}{“author”: “mike”, “text”: “...”}
Dynamic Queries
Atomic Update Modifiers
Focus on Performance
ReplicationReplica sets (v1.6, july)Master / slave (v1.0)m1m3masterm2slaveslaveslave
Auto-shardingShardsmongodmongodmongod...ConfigServersmongodmongodmongodmongodmongodmongodmongosmongos...client
Many Supported Platforms / Languages
Best Use CasesScaling OutCachingThe WebHigh Volume
Less Good Athighly transactionalad-hoc /offline  business intelligenceproblems that require SQL
A Quick Aside_idspecial keypresent in all documentsunique across a Collectionany type you want
The Administrative Shell (mongo)Examples to follow are in Javascript syntax, but can be done in any language.
Post{author: “mike”, date: new Date(), text: “my blog post...”, tags: [“mongodb”, “intro”]}
Comment{author: “eliot”, date: new Date(), text: “great post!”}
New Postpost = {author: “mike”,  date: new Date(),  text: “my blog post...”,  tags: [“mongodb”, “intro”]}db.posts.insert(post)
Embedding a Commentc = {author: “eliot”,  date: new Date(),  text: “great post!”}db.posts.update({_id: post._id},                 {$push: {comments: c}})
Embedding a Commentc = {author: “eliot”,  date: new Date(),  text: “great post!”}db.posts.update({_id: post._id},                 {$push: {comments: c}})Atomic
Posts by Authordb.posts.find({author: “mike”})Note: queries are JSON!
Last 10 Postsdb.posts.find()        .sort({date: -1})        .limit(10)
Posts Since April 1last_week = new Date(2010, 3, 1)db.posts.find({date: {$gt: last_week}})
Posts Ending With ‘Tech’db.posts.find({text: /Tech$/})
Posts With a Tagdb.posts.find({tags: “mongodb”})...and Fast(multi-key indexes)db.posts.ensureIndex({tags: 1})
Indexing / Querying on Embedded Docs(dot notation)db.posts.ensureIndex({“comments.author”: 1})db.posts.find({“comments.author”: “eliot”})
Counting Postsdb.posts.count()db.posts.find({author: “mike”}).count()
Basic Pagingpage = 2page_size = 15db.posts.find().limit(page_size)               .skip(page * page_size)
Migration: Adding Titles(just start adding them)post = {author: “mike”,        date: new Date(),        text: “another blog post...”,        tags: [“mongodb”],       title: “MongoDB for Fun and Profit”}post_id = db.posts.save(post)
Advanced Queries$gt, $lt, $gte, $lte, $ne, $all, $in, $nin, $ordb.posts.find({$where: “this.author == ‘mike’ ||                        this.title == ‘foo’”})
Other Cool Stuffaggregation and map/reducecapped collectionsunique indexesGridFSgeospatial indexes

Intro to mongodb mongouk jun2010