|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: [PhillyOnRails] Rails and Database Design Issues
|
On Wed, Dec 14, 2005 at 10:27:56PM -0500, Cassius Rosenthal wrote:
> >Even if Ruby dislikes stored procedures (sorry to hear that!),
> It's not that Ruby dislikes stored procedures. Rails can still call
> stored procedures, but as far as I know it would necessitate sql
> statements everywhere in the model, which would invalidate all of the
> work that went into the Rails object/relation mapping. That's part of
> the big problem for postgresql, or any advanced database usage. Am I
> wrong on this?
No, you're right on the money. But there's more:
So, I'm not a database expert by any means, but it seems that there is a
lot of pushback from newcomers to Rails about the lack of integrated
stored procedure support. This should, however, not surprise anyone. Rails
is basically an ORM, which maps _data_ from objects to a relational
database system. It does not map _code_, which is what a stored procedure
is. A stored procedure is code in the same way that methods on your
objects are code. But since a stored procedure is not data, there's no
general way to map between the O and the R in this case. Finally, stored
procedures are an artifact of the RDBMS itself; they exist to overcome
some of the limitations of the RDBMS implementation. (speed, mostly)
I understand that most people working with RDBMSs for long periods of time
get very ingratiated with the idea of using stored procedures everywhere,
but I find that most of those same people have ignore the real purpose
of a stored procedure. (make an oft-run SQL query go faster) Other levels
of optimisation are available in almost all cases.
In Rails' defense I would also state that it was never designed to be
bolted onto a large legacy DB schema, but rather designed for small teams
of Web-centric developers to create new apps simply and cheaply. Stored
procedures just don't fit that model, and that doesn't invalidate their
use, but it does explain why they aren't a first class feature in
Rails. (and might not ever be)
Its OK to say that Rails isn't the right framework for the task at hand.
If you have a lot of stored procedures, you're not going to get a lot of
benefit from the current Rails framework and you should probably look
elsewhere for your ORM needs. Call me a heretic, but I've seen things like
this come and go and trying to leverage a solution that doesn't fit the
problem has got to be one of the top 5 sources of wasted time and effort
that I could think of.
--
Toby DiPasquale
_______________________________________________
talk mailing list
talk@phillyonrails.org
http://lists.phillyonrails.org/mailman/listinfo/talk
|
|