Thought I'd post this here since the OCRuby group submission is moderated.
This is mainly interesting for the Mongo DB presentation by Tommy Chheng.
Attendees:
Dash
Tina
Michael Hartl
Tommy Chheng
Scott Smith
Michael has published 7 chapters of his electronic book at railstutorial.org
Tommy: Whither Mongo DB for Natural Development
Used by:
- github
- EA
- The New York Times
- sourceforge
- The Business Insider
The above are "big" sites.
Why?
- NoSQL trend?
- Scalability?
- Natural Development!
Compare
SQL fixed schema
- Data model Rows/Tables
- Data Types Primitives
MongoDB Dynamic
- BSON Documents/Collections
- Primitives+Arrays/Hashes
Records vs Documents
SQL
3 tables
- Documents
- Revisions
- Tags
MongoDB
- document = {title:...} (reads as Javascript code)
- BSON data structure naturally maps to most programming languages hash object.
- ORM can just be a thin layer.
- Can debug Mongo a lot easier.
Mongo Install
- http://www.mongodb.org/display/DOCS/Quickstart
- Chef recipe available
- http://github.com/schisamo/
- chef_cookbooks/
- Start server: ./mongod
- Run console: mongo
- Works with javascript as the query language
How to use in Ruby?
Easy to use in Rails or Sinatra
2 gems
- mongo+mongo_ext gem
- mongo_mapper gem
MongoMapper Models
- No Migrations!
- AR Validations
- AR Callbacks
- Testing using Facory Girl
- Rails 3?
- fork which uses ActiveModel, see mailinglist
- is complete but not merged in yet.
MongoMapper Model
(sample code)
CouchDB or MongoDB?
CouchDB
- One big database
- HTTP REST
- Find by id ma/reduce JS functions
- MVCC
MongoDB
- Many collections
- sockets
- Find by id - dynamic JS queries
- Update in place
MVCC - updates by making new version copy; good for data safety.
Update in place is a lot faster
MongoDB by default writes to disk in batches
Limitations
Memory Mapped file:
- 32-bit 4GB limit, use 64-bit
Atomic updates only at document level
- Solve by nesting related data in document
MongoDB lacks:
- transactions
- CouchDB-style MVCC revisioning
Author
Twitter @tommychheng
Side project: http://nextsprocket.com/
- using mongoDB + mongo_mapper!