Successfully reported this slideshow.

Webinar: Building Your First MongoDB App

3,812 views

Published on

This webinar will walk you through building a simple location-based check-in app in MongoDB. We’ll cover the basics of MongoDB’s document model, query language, map reduce framework, and deployment architecture.

In this webinar you will discover:

- Why MongoDB is being adopted in organizations large and small
- How easy it is to start building applications with MongoDB
- Key features for manipulating and accessing data
- High availability and scale-out architecture

Published in: Technology
  • Be the first to comment

Webinar: Building Your First MongoDB App

  1. 1. #MongoDB Building your first app; an introduction to MongoDB Rick Houlihan Solutions Architect, MongoDB
  2. 2. What is MongoDB?
  3. 3. MongoDB is a ___________ database • Document • Open source • High performance • Horizontally scalable • Full featured
  4. 4. Document Database • Not for .PDF & .DOC files • A document is essentially an associative array • Document = JSON object • Document = PHP Array • Document = Python Dict • Document = Ruby Hash • etc
  5. 5. Open Source • MongoDB is an open source project • On GitHub • Licensed under the AGPL • Started & sponsored by MongoDB Inc (formerly 10gen) • Commercial licenses available • Contributions welcome
  6. 6. High Performance • Written in C++ • Extensive use of memory-mapped files i.e. read-through write-through memory caching. • Runs nearly everywhere • Data serialized as BSON (fast parsing) • Full support for primary & secondary indexes • Document model = less work
  7. 7. Database Landscape
  8. 8. Full Featured • Ad Hoc queries • Real time aggregation • Rich query capabilities • Strongly consistent • Geospatial features • Support for most programming languages • Flexible schema
  9. 9. mongodb.org/downloads
  10. 10. Running MongoDB $ tar –z xvf mongodb-osx-x86_64-2.4.x.tgz $ cd mongodb-osx-i386-2.4.4/bin $ mkdir –p /data/db $ ./mongod
  11. 11. Mongo Shell MacBook-Air-:~ $ mongo MongoDB shell version: 2.4.4 connecting to: test > db.test.insert({text: 'Welcome to MongoDB'}) > db.test.find().pretty() { "_id" : ObjectId("51c34130fbd5d7261b4cdb55"), "text" : "Welcome to MongoDB" }
  12. 12. Document Database
  13. 13. Terminology RDBMS MongoDB Table, View ➜ Collection Row ➜ Document Index ➜ Index Join ➜ Embedded Document Foreign Key ➜ Reference Partition ➜ Shard
  14. 14. Let’s Build a Blog
  15. 15. First step in any application is Determine your entities
  16. 16. Entities in our Blogging System • Users (post authors) • Article • Comments • Tags
  17. 17. In a relational base app We would start by doing schema design
  18. 18. Typical (relational) ERD
  19. 19. In a MongoDB based app We start building our app and let the schema evolve
  20. 20. MongoDB ERD
  21. 21. Working With MongoDB
  22. 22. Start with an object (or array, hash, dict, etc) var user = { username: ’erlichson', first_name: ’Andrew', last_name: ’Erlichson', }
  23. 23. Switch to Your DB >db test > use blog switching to db blog > db.users.insert( user )
  24. 24. Insert the Record > db.users.insert(user) No collection creation necessary
  25. 25. Find One Record > db.users.findOne() { "_id" : ObjectId("50804d0bd94ccab2da652599"), "username" : ”erlichson", "first_name" : ”Andrew", "last_name" : ”Erlichson" }
  26. 26. Creating a Blog Post > db.article.insert({ title: ‘Hello World’, body: ‘This is my first blog post’, date: new Date(‘2013-06-20’), username: ‘erlichson’, tags: [‘adventure’, ‘mongodb’], comments: [ ] })
  27. 27. Finding the Post > db.article.find().pretty() { "_id" : ObjectId("51c3bafafbd5d7261b4cdb5a"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : "erlichson", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  28. 28. Querying An Array > db.article.find({tags:'adventure'}).pretty() { "_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"), "title" : "Hello World", "body" : "This is my first blog post", "date" : ISODate("2013-06-20T00:00:00Z"), "username" : "erlichson", "tags" : [ "adventure", "mongodb" ], "comments" : [ ] }
  29. 29. Using Update to Add a Comment > db.article.update({_id: new ObjectId("51c3bcddfbd5d7261b4cdb5b")}, {$push:{comments: {name: 'Steve Blank', comment: 'Awesome Post'}}}) >
  30. 30. Post with Comment Attached > db.article.findOne({_id: new ObjectId("51c3bcddfbd5d7261b4cdb5b")}) { "_id" : ObjectId("51c3bcddfbd5d7261b4cdb5b"), "body" : "This is my first blog post", "comments" : [ { "name" : "Steve Blank", "comment" : "Awesome Post" } ], "date" : ISODate("2013-06-20T00:00:00Z"), "tags" : [ "adventure", "mongodb" ], "title" : "Hello World", "username" : "erlichson" }
  31. 31. MongoDB Drivers
  32. 32. Real applications are not built in the shell
  33. 33. MongoDB has native bindings for over 12 languages
  34. 34. docs.mongodb.org
  35. 35. Online Training at MongoDB University
  36. 36. We've introduced a lot of concepts here
  37. 37. Schema Design @
  38. 38. Replication @
  39. 39. Indexing @
  40. 40. Sharding @
  41. 41. Questions?
  42. 42. #MongoDBWorld MongoDB World New York City, June 23-25 See what’s next in MongoDB including • MongoDB 2.6 • Sharding • Replication • Aggregation http://world.mongodb.com Save $200 with discount code THANKYOU
  43. 43. #ConferenceHashtag Thank You Rick Houlihan Solutions Architect, MongoDB

×