Faster, Better, ORM with DataMapper

Location: E145 - E146 Level: Expert
Average rating: ****.
(4.47, 19 ratings)

DataMapper is an ORM that was created as an alternative database layer for Ruby web frameworks like Rails. DataMapper has a number of advantages over the built-in ActiveRecord, and Rails developers can drop it in as an alternative.

This talk will focus on the architecture of DataMapper, and as such, will be most appropriate for advanced-level Rails programmers. It will involve both intensive code-reading, as well as a more general walk-though of the mechanisms used by DataMapper to serve as a bridge between the database and Ruby.

The talk will discuss integrating DataMapper into Rails, and using DataMapper models in Rails controllers or as Rails resources in Rails 2.0. It will also discuss using ActiveRecord and DataMapper side-by-side, either in an integrated project or in the process of migrating an existing Rails app over to DataMapper.

It will also include a brief discussion of the way that DataMapper relies on its sister DO.rb project, which provides a unified interface for communicating with database drivers, and frees the ORM layer to handle ORM concerns, instead of lots of code branches to handle the way the different drivers do things like opening and closing connections to the database.

DataMapper has some very interesting characteristics:

  • It has an IdentityMap, so a single object will always represent a single database row.
  • It supports lazy-loading by default, so you can prevent large columns from being loaded in until they are needed
  • It eager-loads associations, so {|x| } will only execute two queries (instead of N + 1)
  • It only saves columns that were changed, which dramatically speeds up updates
  • It has excellent support for legacy database schemas and multiple databases, even within a single model
  • It has nice simplifiers for queries like Person.all( => 20) or Person.all(:name.not => [“tom”, “ben”])
Photo of Yehuda Katz

Yehuda Katz

Tilde Inc

Yehuda Katz is a core team member on the DataMapper project, and the creator of the DO.rb project. He is a contributor to the Merb and Rubinius projects, and is a contributing author for the upcoming Manning Publications book Ruby in Practice.

He recently accepted a job at EngineYard. He has been working on Ruby on Rails applications since 2005, and has just spent a year working on a very large and complex data-driven Rails app (

He also does front-end web work, is a coauthor of the Manning book jQuery in Action and a core team member of the jQuery project.

News and Coverage
co-presented by Ruby Central, Inc. O'Reilly
  • Engine Yard
  • Sun Microsystems
  • FiveRuns
  • GotThingsDone
  • Heroku
  • ThoughtWorks
  • Atlantic Dominion Solutions
  • Blue Box Group
  • CodeGear
  • E-xact
  • ELC Technologies
  • EnterpriseDB
  • GemStone Systems
  • Intridea
  • Morph Labs
  • RightScale
  • TechRepublic

Sponsorship Opportunities

For information on exhibition and sponsorship opportunities at RailsConf, contact Yvonne Romaine.

Download the RailsConf Sponsor/Exhibitor Prospectus

Media and Promotional Opportunities

Download the Media & Promotional Partner Brochure (PDF) for more information on trade opportunities with O'Reilly conferences, or contact mediapartners@

Program Ideas

Post your suggestions for speakers, topics, and activities on the RailsConf wiki or send an email to

Press and Media

For media-related inquiries, contact

Contact Us

View a complete list of RailsConf 2008 contacts.