The MongoDB Metamorphosis: Thinking about Data as Documents
Inspired by the developing NoSQL movement, many of us Rails developers have gravitated towards MongoDB, a fast, scalable, schema-free, document-oriented database.
But there’s a problem: we’ve all been thinking in terms of migrations, join tables, normalization, and all the other practices born out of RDBMS. This naturally raises many questions about document-oriented modeling:
- What’s the best way to create a many-to-many relationship, a polymorphic association?
- When do we nest our data, and when is it best kept in separate collections?
- How do we represent common data structures like trees and lists?
- How much denoralization is appropriate?
The first half of the presentation will cover some essential document-based schema design patterns. We’ll consider these in light of MongoDB’s features, as our schemas should always complement the database’s core query, insert, update, and aggregation functions.
Next, we’ll use a common data modeling domain, product catalog management, to contrast RDBMS and document-based modeling strategies. This will shed light on some of the advantages and tradeoffs of moving to a document-oriented system.
Kyle Banker
10gen
Kyle Banker works at 10gen, where he maintains the MongoDB Ruby driver and supports Ruby developers at large. Previously, he built e-commerce and social networking applications in Rails at Alexander Interactive. Originally a languages nerd and a teacher of English lit., Kyle find himself quite at home in the multi-faceted Ruby and Rails communities.
Comments on this page are now closed.


















Comments
@rafael thank you, sir!
One of the best talks this RailsConf, no doubt. Congrats, Kyle.
@john thanks for pointing out the theme of candor. i’m sure i could do better in some cases, but glad to see it came through.
A good overview of MongoDB. What I especially liked was the candor when asked if a specific type of app would be a good candidate for Mongo. Kyle candidly said no give the transactional nature of the app in question. All too often, from proponents of specific technologies, we hear what the technology excels at and not enough about areas where the tech may not be a good fit. IMO, knowing what something cannot do or is not well suited is more important than knowing where the tech excels. Kyle made it very clear, how wide Mongo’s lane of fire is.
@steven Thanks so much! If you’re ever in NYC, definitely stop by and we’ll finally get a chance to meet up.
Kyle, I didn’t get to meetup with you after your talk (one disadvantage of a huge RailsConf over a much smaller RubyNation I suppose), but you absolutely nailed it. Very well done presentation by far the best NoSQL related session that I attended. Just wish I could have met up later to learn some more about the best ways to integrate it with Rails applications. Keep up the great work!
@vince much appreciated.
Excellent talk, thanks Kyle
@matt thanks so much—glad it was helpful!
The e-commerce examples were a huge help for understanding the conceptual shift from “rows” to “documents”. Thanks!
@charles. Yes, I’ll make the slide available afterwards.
Will the presentation or slides be available for this after the event?
Damn excited to see this talk!