These are the slides I used for a MongoDB webinar about creating your first application with MongoDB. They start with a general MongoDB overview, continuing onto how to model data for a metadata catalog. At this point in the presentation, I break to do a live demonstration. Afterwards, I touch on scaling your application with MongoDB.
Building Your First MongoDB App ~ Metadata Catalog
1. Building Your First
Application
Kevin Hanson
Solutions Architect, 10gen
Kevin@10gen.com
@hungarianhc
2. Step 1 - What is mongoDB??
• Scalable, High-Performance, Open Source, Document-
Oriented Database
– JSON (well... BSON) Storage Model
– Indexes and Full Query Language
– Easy for Developers to Pick Up
• More Features at http://www.mongodb.org/
• Overview Video: http://www.10gen.com/what-is-mongodb
5. Parallels
RDBMS MongoDB
Table Collection
Row Document
Column Field
Index Index
Join Embedding / Linking
Schema Object
6. Rich Data Model
{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"),
author : "roger",
date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)",
text : "Spirited Away",
tags : [ "Tezuka", "Manga" ],
comments : [
{
author : "Fred",
date : "Sat Jul 24 2010 20:51:03 GMT-0700 (PDT)",
text : "Best Movie Ever"
}
]}
7. Querying
>db.posts.find()
{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"),
author : "roger",
date : "Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)",
text : "Spirited Away",
tags : [ "Tezuka", "Manga" ] }
Notes:
- _id is unique, but can be anything you’d like
8. Secondary Indexes
Create index on any Field in Document
// 1 means ascending, -1 means descending
>db.posts.ensureIndex({author: 1})
>db.posts.find({author: 'roger'})
{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"),
author : "roger",
... }
17. Indexing / Querying Metadata
// List all people whose name is “John Smith”
> db.posts.ensureIndex( “name”:1 )
db.posts.find({‘name’:’John Smith’})
// List all people whose name is “John Smith”, sorted by
birthday descending
> db.posts.ensureIndex( name: 1, birthday: -1)
> db.posts.find( { name: ’John Smith’ } ).sort({birthday: -1})
// Return people that “Doctor Bob” made notes about, sorted
by their name
> db.posts.ensureIndex( notes.doctor: 1, name: 1)
> db.posts.find( “notes.doctor”: “Doctor Bob”).sort({name:1})
21. Replica Sets
Add Secondaries for High Availability / Read Scale
High Write Load / Big Data Set -> Use mongoDB Range
Based Auto Sharding (A Future Webinar / mongoDB Day)
22. More info at http://www.mongodb.org/
conferences, appearances, and meetups
http://www.10gen.com/events
Kevin Hanson
kevin@10gen.com
@hungarianhc
Facebook | Twitter | LinkedIn
http://bit.ly/mongofb @mongodb http://linkd.in/joinmongo