rod mclaughlin

Rails and 'Clever Databases'

Wed, October 15, 2008

A shock. I decided to upgrade my app to use stored procedures instead of generating SQL to talk to the database. Searching around for how to do it, I discovered that David Heinemeier Hansson, the creator of Ruby on Rails, doesn't like stored procedures - or any constraints in the database - because it's not DRY - the constraints should all be in the Ruby code, not in the database as well.

I beg to differ, to put it mildly.

It's all very well if you ignore performance. security and the fact that relational databases have contained 'business logic' since time immemorial

Why do you have to write business logic in an algorithmic language, rather than SQL?
This whole argument forgets that web apps have only four purposes:
- to enable the user to see data
- to enable the user to add data
- to enable the user to change data
- to enable the user to remove data

The rest is just window-dressing
Stored procedures are essential in a serious web-based database app
What's needed is a variant of Rails that uses Stored Procedures, and only Stored Procedures
Portland London