SlideShare a Scribd company logo
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs
Rails and alternative ORMs

More Related Content

PDF
python and database
DOCX
Ruby on Rails Developer - Allerin
PDF
Struts database access
PDF
자마린.안드로이드 기본 내장레이아웃(Built-In List Item Layouts)
PPTX
TDD in the wild
ODP
Database2
PPTX
Learn PHP Lacture2
PPTX
PostgreSQL's Secret NoSQL Superpowers
python and database
Ruby on Rails Developer - Allerin
Struts database access
자마린.안드로이드 기본 내장레이아웃(Built-In List Item Layouts)
TDD in the wild
Database2
Learn PHP Lacture2
PostgreSQL's Secret NoSQL Superpowers

What's hot (20)

PPT
Zend framework 03 - singleton factory data mapper caching logging
ODP
Data repositories
PDF
Intro to MongoDB and datamodeling
DOCX
MVest Spring Job Execution
PPTX
Google Dorks
PPT
Digesting jQuery
PDF
wtf is in Java/JDK/wtf7?
PDF
Euruko 2009 - DataObjects
PDF
MySQL User Conference 2009: Python and MySQL
PPTX
What's Parse
PDF
Compass Framework
PDF
Scaling / optimizing search on netlog
PPT
Schema design short
PPT
Mysql DBI
PPTX
My_sql_with_php
PPTX
Mongo db
PDF
Android datastorage
DOC
Quiz With Answers Drupal
PDF
Couchbase & FTS
DOCX
Connectivity coding for java and mysql
Zend framework 03 - singleton factory data mapper caching logging
Data repositories
Intro to MongoDB and datamodeling
MVest Spring Job Execution
Google Dorks
Digesting jQuery
wtf is in Java/JDK/wtf7?
Euruko 2009 - DataObjects
MySQL User Conference 2009: Python and MySQL
What's Parse
Compass Framework
Scaling / optimizing search on netlog
Schema design short
Mysql DBI
My_sql_with_php
Mongo db
Android datastorage
Quiz With Answers Drupal
Couchbase & FTS
Connectivity coding for java and mysql
Ad

Viewers also liked (6)

PDF
Designing Great APIs: Learning from Jony Ive, Orwell, and the Kano Model
PDF
Aristotle and the Art of Software Development (Agile 2009)
PDF
Aristotle and the Art of Software Development
PDF
Advanced API Design: how an awesome API can help you make friends, get rich, ...
PDF
Programming and Minimalism: Lessons from Orwell and the Clash
PPT
Pandas Updated2
Designing Great APIs: Learning from Jony Ive, Orwell, and the Kano Model
Aristotle and the Art of Software Development (Agile 2009)
Aristotle and the Art of Software Development
Advanced API Design: how an awesome API can help you make friends, get rich, ...
Programming and Minimalism: Lessons from Orwell and the Clash
Pandas Updated2
Ad

Similar to Rails and alternative ORMs (20)

KEY
[Coscup 2012] JavascriptMVC
PDF
Hands On Spring Data
PDF
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
PDF
Using Document Databases with TYPO3 Flow
PPTX
Sequelize
PDF
Python RESTful webservices with Python: Flask and Django solutions
PDF
Painless Persistence in a Disconnected World
PDF
Data herding
PDF
Data herding
PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
PPTX
Art of Javascript
PPT
SXSW 2012 JavaScript MythBusters
PDF
12 core technologies you should learn, love, and hate to be a 'real' technocrat
PPTX
How Rackspace Cloud Monitoring uses Cassandra
PDF
AJS UNIT-1 2021-converted.pdf
PDF
Rapid Prototyping with Solr
PPTX
REST APIs in Laravel 101
PDF
Spring data requery
PPSX
JDBC Part - 2
PDF
#NoXML: Eliminating XML in Spring Projects - SpringOne 2GX 2015
[Coscup 2012] JavascriptMVC
Hands On Spring Data
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
Using Document Databases with TYPO3 Flow
Sequelize
Python RESTful webservices with Python: Flask and Django solutions
Painless Persistence in a Disconnected World
Data herding
Data herding
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Art of Javascript
SXSW 2012 JavaScript MythBusters
12 core technologies you should learn, love, and hate to be a 'real' technocrat
How Rackspace Cloud Monitoring uses Cassandra
AJS UNIT-1 2021-converted.pdf
Rapid Prototyping with Solr
REST APIs in Laravel 101
Spring data requery
JDBC Part - 2
#NoXML: Eliminating XML in Spring Projects - SpringOne 2GX 2015

Recently uploaded (20)

PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
MIND Revenue Release Quarter 2 2025 Press Release
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
Programs and apps: productivity, graphics, security and other tools
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Machine learning based COVID-19 study performance prediction
sap open course for s4hana steps from ECC to s4
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Empathic Computing: Creating Shared Understanding

Editor's Notes

  • #3: So ... Why use an ORM?
  • #4: Because your database and your OO code are unlike things. Different paradigms. So in a sense, any time you use a relational DB + OO, you’re going to do some sort of object relational mapping. May be formal or informal.
  • #6: So data types are not identical
  • #7: Your DB has a formal definition independent of the use of the data.
  • #8: This is a big one. In OO, you follow references - an object can “point” to another object, and so on. In SQL, you logically join sets of data together.
  • #9: Any bit of data can be joined to any other bit. In OO, ideal is to hide as much as you can and only expose a public interface.
  • #10: declarative vs. active - declare that certain kinds of data are acceptable, vs. actively checking at certain points in time.
  • #11: SQL doesn’t directly have a concept of inheritance. Fundamental to OO.
  • #13: Finally, different purposes. Define structure for data (and hold that data) vs. Doing something
  • #14: So basically, ORM are translators between unlike things. Like any translation,
  • #15: this isn’t going to be perfectly smooth, and there will always be tradeoffs. In this talk, Dan and I are going to talk about these tradeoffs by looking at three approaches to ORM with Ruby.
  • #16: You’re probably familiar with this already, so I won’t show much code here or talk about how to use AR. Instead, let’s talk for a few minutes at a more theoretical level.
  • #17: In this pattern, an object wraps each DB row. This single object handles both domain logic and database access. What's unique about this?
  • #18: Other approaches might not treat each row as an object, or might combine multiple rows into a single object.
  • #19: Others might separate these, filtering the data through a logic layer, instead of exposing both side-by-side.
  • #22: class User < ActiveRecord::Base end That does a _lot_. And from looking at this, you have no idea exactly what it did. You have to check the db schema in order to figure that out. The good news is that convention dominates. Once you know the conventions, you generally aren't surprised.
  • #23: This is true, by default. N+1, loads all columns, etc. It would be really nice if it could do these things. But at the same time, it provides facilities for these sorts of optimizations.
  • #24: This is part of the reason that alternative ORMs got started. The thing is, it isn't true any more. At least not entirely.
  • #25: This guy, Josh Peek, made Rails 2.2 thread safe.
  • #26: And this guy, who you may recognize, added the current connection pooling.
  • #27: The fact is, as a AR developer, you can pretty much forget how to write a join. This isn't really a limitation of AR - some could say that it&#x2019;s a feature. But at the same time, you really do need to know SQL if you&#x2019;re going to use a relational database. That said, my SQL skills have atrophied as a Rails developer. On our newest project, Luke and I have had to do quite a bit of custom SQL, and we've tried to make our DB layer a bit smarter and more robust. Which leads to the next criticism...
  • #28: Rails makes polymorphic associations easy and multi-table inheritance hard. But polymorphic associations: bad idea. Cuts out a join table, but hurts referential integrity. But because it&#x2019;s easy, you see a lot of it. Is this a valid criticism? It usually isn&#x2019;t that hard to fight against AR&#x2019;s conventions, and most of the time, you don&#x2019;t want to.
  • #29: This is bad. Basically, foreign keys require a plugin. Redhill. This plugin works, but isn't all that actively maintained, and some things (constraints) aren't even supported by that. You can always run a bare connection.execute() statement, but this won't get dumped into your schema.rb file, which is bad. According to DHH et al, you don't need DB constraints, and you want a dumb DB.
  • #34: 4. Access your database directly.
  • #36: Company 1 may not exist. Or
  • #38: I.e. you make a mistake
  • #39: I.e. you make a mistake. This probably isn&#x2019;t a problem for you, but it might be for some of the other people you work with.
  • #40: Sequel is a thread-safe DB library with a lightweight ORM
  • #41: Follows the ActiveRecord pattern
  • #42: So you don&#x2019;t have to write much real SQL
  • #43: So you don&#x2019;t have to write much real SQL
  • #44: The Sequel ORM is very similar to AR, at least on the surface. Does many of the things that Rails does, at least the basics.
  • #47: Also has similar support for sharding