At 12:22 AM -0500 6/14/02, Dave Rolsky wrote:
>An Object-Relational mapper takes objects and stores them in a relational
>database, as transparently as possible. I think the most pure example of
>this I've seen in the Perl world is Tangram (www.tangram-persistence.org).
>SPOPS is also an O-R mapper (actually, its a generic Object persistence
>mechanism but it seems to most feature-rich when used with an RDBMS).
>
>A Relational-Object takes a relational database, and provides access to it
>(select, insert, update, delete) via objects. Class::DBI, Alzabo, and
>DBIx::RecordSet are examples of such a beast.
>
>I think what it comes down to is "how do you start thinking your project?"
Well said, Dave. I don't think one approach is strictly better than
the other. It depends what you need to accomplish. I wouldn't be
surprised to find that the majority of the folks on the modperl list
would favor an R-O approach to an O-R one, but that's because
probably the vast majority of web apps are primarily about the data.
This happens to not be the case for me and I find my O-R mapper to be
enormously helpful, exactly what I need most of the time. I'm using
ESPOPS, a package built on top of SPOPS to handle objects with
inherited attributes spread across multiple tables. Granted, when I
do need to fetch my objects based on complicated criteria involving
joining of lots of tables, it's not as clean as I'd like. It requires
passing SQL fragments into the fetch methods.
To me this just means that my O-R mapper has abstracted things nicely
to the point where I don't have to touch any SQL 90% of the time, but
for those cases where I do need more complicated SQL, it lets me
directly at the SQL and doesn't pretend that it's going to be able to
do everything I might want. This seems like a good tradeoff to me.
One possible improvement (with emphasis on possible) might be to
build the O-R mapper on top of something like Alzabo or some other
R-O mapper which does a more complete job of abstracting me away from
the actual SQL. Then when I want to pass some more explicit query
specs through the O-R mapper it would be in "Alzabo" instead of SQL.
My gut feeling is that the extra layer probably wouldn't be worth it.
Anyway, my main point is O-R and R-O are different tools for
different jobs. A hammer is not better than a saw until you know
you're trying to drive a nail as opposed to cut wood.
BTW, this thread should probably be moved to the poop list ...
--
Ray Zimmerman / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall
Sr Research / phone: (607) 255-9645 / Cornell University
Associate / FAX: (815) 377-3932 / Ithaca, NY 14853