• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to NoSQL and MongoDB
 

Introduction to NoSQL and MongoDB

on

  • 3,747 views

 

Statistics

Views

Total Views
3,747
Views on SlideShare
3,599
Embed Views
148

Actions

Likes
2
Downloads
0
Comments
0

6 Embeds 148

http://nullability.org 104
http://www.slideshare.net 37
http://www.locawebers.com.br 2
https://twimg0-a.akamaihd.net 2
http://us-w1.rockmelt.com 2
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Introduction to NoSQL and MongoDB Introduction to NoSQL and MongoDB Presentation Transcript

  • MongoDB Daniel Quirino Oliveira daniel@nullability.org
  • “... a scalable, high-performance, open-source, schema-free, document-oriented database” (http://mongodb.org)
  • Document-oriented means...
  • No tables (at least, not in the relational model sense)
  • No columns (or uniformly-sized fields for a record)
  • i.e., different instances of a given document may have a different structure (and they name all this “schema-free”)
  • Not necessarily ACID (transactional behaviour makes any sense for you?)
  • Not necessarily ACID (transactional behaviour makes any sense for you?)
  • ACID?
  • Atomicity “it’s all or nothing” Consistency “DB will remain consistent” Isolation “one transaction cannot affect other” Durability “once TX successfully ends, data will be saved”
  • Not necessarily ACID (transactional behaviour makes any sense for you?)
  • Maybe not...
  • Most NoSQL DBs are deployed in a distributed fashion...
  • ... (master-slave, master-slave +replica, sharding, etc) ...
  • ... so how do you ensure scalability AND consistency in ACID-compliant manner? (tricky, huh?)
  • Well, you don’t. In the NoSQL world, you trade consistency in favour of scalability
  • - One of the consistency models used in parallel programming; - The eventual consistency model states that, when no updates occur for a long period of time, eventually all updates will propagate through the system and all the replicas will be consistent. MongoDB: consistency at doc level CouchDB: idem, at instance level Basho: eventually consistent
  • Ok, and Mongo?
  • Documents are stored into collections and each document is JSON* object ... (* - binary JSON, named BSON)
  • ... over a distributed “FS” named GridFS (http://blog.mongodb.org/post/183689081/storing-large-objects-and-files-in-mongodb)
  • Collections ≈ Tables Documents ≈ Tuples Attributes ≈ Columns
  • And relationships?
  • A document may refer other document (1-1, 1-n, ...), just like in the relational model
  • contact = {_id: ObjectId(“3eab2389b1”), name: “John”, email: “john@email.com, address: ObjectId(“4d70923ff2”)}; address = {_id: ObjectId(“4d70923ff2”), city: “Sao Paulo”, country: “Brazil”}
  • A document may contain other documents (embedded documents).
  • contact = { _id: ObjectId(“3eab2389b1”), name: “John”, email: “john@email.com, address: { city: “Sao Paulo”, country: “Brazil” } };
  • Drivers for Java, Ruby, Python, C++... (http://www.mongodb.org/display/DOCS/Drivers)
  • Queries in Javascript o/
  • var cursor = db.my_coll.find() cursor.forEach(function(i){print(i)}) var c = db.my_coll.find({name:”Daniel”}) // select * from my_coll where name = “Daniel” var c = db.my_coll.find({$where: “this.name == ‘Daniel’”}) var x = db.my_coll.find({name:”Daniel”}).count() ... http://www.mongodb.org/display/DOCS/Querying
  • Demo
  • Hosted MongoDB for free at http://mongohq.com
  • TRY IT!
  • Questions?
  • Thanks :)