Seedhack MongoDB 2011

755 views
669 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
755
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Seedhack MongoDB 2011

    1. 1. An introduction to MongoDB Russell Smith
    2. 2. /usr/bin/whoami• Russell Smith• Consultant for UKD1 Limited,• External consultant for 10gen• Help with code, architecture, infrastructure, devops, sysops, capacity planning, etc• <3 MongoDB, MySQL, Redis, Gearman, Neo4j, Kohana, Riak, PHP, Debian, AWS, etc
    3. 3. What is MongoDB• A scalable, high-performance, open source, document-oriented database.• Stores JSON like documents• Commercially backed by 10gen
    4. 4. Why choose it?• Schema-less• Simple• Reliable• Scalable• Drivers
    5. 5. Who uses it?• Foursquare• Disney• Craigslist• MTV Networks• O2• Telefonica
    6. 6. Basics• insert• find• update• remove• ensureIndex
    7. 7. Insert• db.test.insert({hello: ‘world’});
    8. 8. Find• db.test.find()• Equivalent of SELECT * FROM test;> db.test.insert({hello: ‘world’});> db.test.find();{ "_id" : ObjectId("4e7c9f464bdd7534bc498ff7"), "hello" : "world" }
    9. 9. Updating• db.test.update(<condition>, <operation>)> db.test.find();{ "_id" : ObjectId("4e7c9f464bdd7534bc498ff7"), "hello" : "world" }> db.test.update({hello:‘world’}, {hello: ‘seedhack’});> db.test.find();{ "_id" : ObjectId("4e7c9f464bdd7534bc498ff7"), "hello" : "seedhack" }
    10. 10. Removing• db.test.remove(<condition>)> db.test.find();{ "_id" : ObjectId("4e7c9f464bdd7534bc498ff7"), "hello" : "seedhack" }> db.test.remove({hello: ‘seedhack’});> db.test.count()0>
    11. 11. Indexes• It’s usually a good idea to index your collections• How and which columns depends on what you are doing• explain> db.test.ensureIndex({hello:1})
    12. 12. More advanced• sort, count, limit, special operators• Capped collections• Geospatial indexing• MapReduce• Replica sets• Sharding
    13. 13. Getting started...• Download & install - http://www.mongodb.org/downloads• Online shell - http://www.mongodb.org/
    14. 14. Questions / Further• Come and ask me questions• Updates can also push, set, increment, decrement, etc http://bit.ly/gEfKOr• Indexes can be across multiple keys, 2D (geo) and ASC / DESC http://bit.ly/hpK68Q• SQL -> Mongo chart http://bit.ly/ig1Yfj

    ×