• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Latinoware
 

Latinoware

on

  • 1,472 views

 

Statistics

Views

Total Views
1,472
Views on SlideShare
1,471
Embed Views
1

Actions

Likes
1
Downloads
17
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Latinoware Latinoware Presentation Transcript

    • base de dados orientada a documentos para aplicações Web Kristina Chodorow
    • Who am I? Software Engineer at Here from New York City
    • Why Use Non-Relational DBs?
    • CAP • Consistency nome : "joe" nome : "joe" • Availability • Partitioning
    • Key-Value Stores Key Value foo bar x 123 ts 6:13:26 12/3/1945 data x9Fx44x1e Tokyo Cabinet, Dynamo, MemcacheDB
    • Key-Value Stores •Fast •Too simple •Simple
    • Column-Oriented Cassandra
    • Document-Oriented { date : Date(2007-05-07), time : { start : 9.25, end : 10.25 } sum : 0, comments : ["task 1", "run 4", "testing module"] } vs.
    • Consistency Availability Partitioning
    • Consistency Availability master Partitioning slave
    • Consistency Availability Partitioning slave
    • Consistency Availability Partitioning master
    • Consistency Availability slave Partitioning master
    • Consistency Availability Partitioning Pair Router Pair Pair ...eventual consistency
    • Introduction to MongoDB
    • A JavaScript Database $ mongodb-linux-1.0/bin/mongo MongoDB shell version: 1.0.0 url: test connecting to: test type "help" for help >
    • JSON and BSON Strict JSON types: { x : null, y : true, z : 123, w : "xyz", a : { b : 1 }, c : [1, 2, 3] } Mongo JSON adds: { ts : new Date(), query : /regex/ig, _id : new ObjectId() }
    • Collections, not Tables
    • Collections { date : Date(2007-05-07), time : { start : 9.25, end : 10.25 } sum : 0, comments : ["task 1", "run 4"] }
    • Using the Shell > db test > use xyz > db xyz > db.splorch.find() >
    • Inserting > db.foo.insert({name : "Joe", age : 34}) > db.foo.find({name : "Joe"}) { "_id" : ObjectId("2fe3e4d892aa73234c910bed"), "name" : "Joe", "age" : 34 }
    • Object Ids an autogenerated primary key "_id" : ObjectId("2fe3e4d892aa73234c910bed") 12 bytes: 2fe3e4d892aa73234c910bed |------||----||--||----| ts mac pid inc
    • Nested Objects > db.blog.insert({title : "First Post", content : "Hello, world!", author : {name : "Joe", id : 123}, comments : [] })
    • Querying posts = db.blog.find({ "author" : "Joe"}) commentsByFred = db.blog.find({ "comments.author" : "Fred"}) commentedByFred = db.blog.find({ "comments.author" : /fred/i})
    • Speaking of indexing… db.people.ensureIndex({"age" : 1}); db.people.ensureIndex({ "name" : -1, "ts" : -1, "comments.author" : 1 });
    • Updating db.blog.update({title : "First Post"}, { $push : { comments : { author : "Fred", comment : "Dumb post." } } });
    • …which gives us: > db.blog.findOne() { _id : ObjectId("4ae06192213900000000745c"), "title" : "First Post", "content" : "Hello, world!" "author" : {"name" : "Joe", "id" : 123} "comments" : [{ "author" : "Fred", "comment" : "Dumb post" }] }
    • $ instead of >, <, =, etc. $gt, $gte, $lt, $lte, $eq, $neq, $exists, $set, $mod, $where, $in, $nin, $inc $push, $pull, $pop, $pushAll, $popAll db.foo.bar.find({x : {$gt : 4}})
    • $where db.blog.findOne({$where : 'this.y == (this.x + this.z)'}); Will work: {"x" : 1, "y" : 4, "z" : 3} {"x" : "hi", "y" : "hibye", "z" : "bye"} Won’t work: {"x" : 1, "y" : 1}
    • Optimizing $where db.blogs.findOne({ name : "Sally", age : {'$gt' : 18}, $where : 'Array.sort(this.interests)[2] == "volleyball"'});
    • Cursors cursor = db.blah.find(array("foo" : "bar")) while (cursor.hasNext()) { obj = cursor.next() }
    • Applications
    • soliMAP @trackmeet FetLife Dextify2
    • Paging cursor = db.results.find() .sort({"ts" : -1}) .skip(page_num * results_per_page) .limit(results_per_page);
    • Logging • insert/update/remove is fast • Capped collections • Schemaless • $inc for counts
    • Storing Files Max: 4Mb
    • Storing Files (More than 4 Mb)
    • Storing Files J J J chunks J J J J J J _id : J files
    • Storing Files ObjectId fileId = new ObjectId(); fileObj = { _id : fileId, filename : "ggbridge.png", user : "joe", takenIn : "San Francisco" } chunkObj = { fileId : fileId, chunkNum : N data : <binary data> }
    • Aggregation group =~ GROUP BY Map/Reduce db.runCommand({ mapreduce : <collection>, map : <mapfunction>, reduce : <reducefunction> [, query : <query filter object>] [, out : <outputcollectionname>] [, keeptemp: <true|false>] [, finalize : <finalizefunction>] })
    • www.mongodb.org
    • Drivers C#, Erlang, Factor
    • Thank you! kristina@10gen.com @kchodorow @mongodb irc.freenode.net#mongodb www.mongodb.org