open-source, high-performance,
schema-free, document-oriented
           database
One-Size-Fits-All
  No Longer
                               RDBMS
                          (Oracle, MySQL)




         ...
NoSQL really means:

non-relational next generation
operational datastores and databases
Scaling out
no joins +
light transactional semantics =
  horizontally scalable architectures
Data models
no joins +
light transactional semantics =
  horizontally scalable architectures

important side effect :
 new...
Data Models
Key/Value


Tabular


Document-based
Data Models
Key/Value
 memcached, dynamo, voldemort


Tabular
 bigtable, cassandra, hbase, hypertable


Document-oriented
...
JSON-style documents
Schema-free

• Loosening constraints - added flexibility
• Dynamically typed languages
• Migrations
Dynamic queries

• Administration
• Ease of development
• Familiarity
Focus on performance
Replication
Auto-sharding
Many supported
platforms / languages
Good at

• The web
• Caching
• High volume data
• Scalability
Less good at

• Highly transactional
• Ad-hoc business intelligence
• Problems that require SQL
MongoDB Basics
Document

• Unit of storage (think row)
• BSON (Binary JSON)
• Represented is language dependent
Collection

• Schema-free equivalent of a table
• Logical groups of documents
• Indexes are per-collection
_id

• Special key
• Present in all documents
• Unique across a Collection
• Any type you want
Blog back-end
Post

{author: “mike”,
 date: new Date(),
 text: “my blog post...”,
 tags: [“mongodb”, “codemash”]}
Comment


{author: “eliot”,
 date: new Date(),
 text: “great post!”}
New post

post = {author: “mike”,
  date: new Date(),
  text: “my blog post...”,
  tags: [“mongodb”, “codemash”]}

db.post...
Embedding a comment

c = {author: “eliot”,
  date: new Date(),
  text: “great post!”}

db.posts.update({_id: post._id},
  ...
Posts by author


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

db.posts.find()
        .sort({date: -1})
        .limit(10)
Posts in the last week


last_week = new Date(2010, 0, 6)

db.posts.find({date: {$gt: last_week}})
Posts ending with
          ‘Mash’


db.posts.find({text: /Mash$/})
Posts with a tag
db.posts.find({tags: “mongodb”})




          ... and fast
db.posts.ensureIndex({tags: 1})
Counting posts


db.posts.count()

db.posts.find({author: “mike”}).count()
Basic paging

page = 2
page_size = 15

db.posts.find().limit(page_size)
               .skip(page * page_size)
Migration: adding titles
  • Easy - just start adding them:
post = {author: “mike”,
        date: new Date(),
        text...
Advanced queries


    • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin
    • where()
db.posts.find({$where: “this.author == ‘...
Other cool stuff

• Aggregation and map reduce
• Capped collections
• Unique indexes
• Mongo shell
• GridFS
• Download MongoDB
  http://www.mongodb.org

• Try it out
• Let us know what you think!
• http://www.mongodb.org
• irc.freenode.net#mongodb
• mongodb-user on google groups
• @mongodb, @mdirolf
• mike@10gen.com
...
MongoDB at CodeMash 2.0.1.0
Upcoming SlideShare
Loading in...5
×

MongoDB at CodeMash 2.0.1.0

3,511

Published on

Presentation on MongoDB from CodeMash 2010 in Sandusky

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,511
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
102
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide
  • Collection (logical groupings of documents)
    Indexes are per-collection
  • blog post
    twitter
  • MongoDB at CodeMash 2.0.1.0

    1. 1. open-source, high-performance, schema-free, document-oriented database
    2. 2. One-Size-Fits-All No Longer RDBMS (Oracle, MySQL) Non-relational New gen. OLAP (vertica, aster, greenplum) operational stores (“NoSQL”)
    3. 3. NoSQL really means: non-relational next generation operational datastores and databases
    4. 4. Scaling out no joins + light transactional semantics = horizontally scalable architectures
    5. 5. Data models no joins + light transactional semantics = horizontally scalable architectures important side effect : new data models = improved ways to develop applications
    6. 6. Data Models Key/Value Tabular Document-based
    7. 7. Data Models Key/Value memcached, dynamo, voldemort Tabular bigtable, cassandra, hbase, hypertable Document-oriented mongodb, couchdb. JSON stores
    8. 8. JSON-style documents
    9. 9. Schema-free • Loosening constraints - added flexibility • Dynamically typed languages • Migrations
    10. 10. Dynamic queries • Administration • Ease of development • Familiarity
    11. 11. Focus on performance
    12. 12. Replication
    13. 13. Auto-sharding
    14. 14. Many supported platforms / languages
    15. 15. Good at • The web • Caching • High volume data • Scalability
    16. 16. Less good at • Highly transactional • Ad-hoc business intelligence • Problems that require SQL
    17. 17. MongoDB Basics
    18. 18. Document • Unit of storage (think row) • BSON (Binary JSON) • Represented is language dependent
    19. 19. Collection • Schema-free equivalent of a table • Logical groups of documents • Indexes are per-collection
    20. 20. _id • Special key • Present in all documents • Unique across a Collection • Any type you want
    21. 21. Blog back-end
    22. 22. Post {author: “mike”, date: new Date(), text: “my blog post...”, tags: [“mongodb”, “codemash”]}
    23. 23. Comment {author: “eliot”, date: new Date(), text: “great post!”}
    24. 24. New post post = {author: “mike”, date: new Date(), text: “my blog post...”, tags: [“mongodb”, “codemash”]} db.posts.save(post)
    25. 25. Embedding a comment c = {author: “eliot”, date: new Date(), text: “great post!”} db.posts.update({_id: post._id}, {$push: {comments: c}})
    26. 26. Posts by author db.posts.find({author: “mike”})
    27. 27. Last 10 posts db.posts.find() .sort({date: -1}) .limit(10)
    28. 28. Posts in the last week last_week = new Date(2010, 0, 6) db.posts.find({date: {$gt: last_week}})
    29. 29. Posts ending with ‘Mash’ db.posts.find({text: /Mash$/})
    30. 30. Posts with a tag db.posts.find({tags: “mongodb”}) ... and fast db.posts.ensureIndex({tags: 1})
    31. 31. Counting posts db.posts.count() db.posts.find({author: “mike”}).count()
    32. 32. Basic paging page = 2 page_size = 15 db.posts.find().limit(page_size) .skip(page * page_size)
    33. 33. Migration: adding titles • Easy - just start adding them: post = {author: “mike”, date: new Date(), text: “another blog post...”, tags: [“codemash”], title: “Review from CodeMash”} post_id = db.posts.save(post)
    34. 34. Advanced queries • $gt, $lt, $gte, $lte, $ne, $all, $in, $nin • where() db.posts.find({$where: “this.author == ‘mike’”})
    35. 35. Other cool stuff • Aggregation and map reduce • Capped collections • Unique indexes • Mongo shell • GridFS
    36. 36. • Download MongoDB http://www.mongodb.org • Try it out • Let us know what you think!
    37. 37. • http://www.mongodb.org • irc.freenode.net#mongodb • mongodb-user on google groups • @mongodb, @mdirolf • mike@10gen.com • http://www.slideshare.net/mdirolf
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×