[sf-perl] ORM vs. DBI

Michael Friedman friedman at highwire.stanford.edu
Sun Feb 27 10:38:04 PST 2011


Without the SQL, the main thing an ORM gives you is the design pattern "Use a Class for each table in your db" (I forget the actual name of the pattern). So what you're saying is that you would use an ORM to make laying out your data access classes easier, using a standard model. Is that right?

That makes sense to me. Right now the system I work with happens to use "one class = one table" design, but it would be a nice shorthand to say "It's DBIx::Class based." As it is, I need to hand people the data model diagram and then explain how we've named classes that don't quite match the table names, which are views are pretending to be tables, and so on. It takes a while. ;-)

Thanks,
-- Mike
______________________________________________________________________________
Mike Friedman | HighWire Press, Stanford Univ | friedman at highwire.stanford.edu

On Feb 26, 2011, at 11:04 PM, David Fetter wrote:

> On Sat, Feb 26, 2011 at 11:00:37PM -0800, Michael Friedman wrote:
>> Fellow Perl Mongers,
>> 
>> I finally got around to reading up on and trying out DBIx::Class. It
>> looks pretty neat, but after loading up a complex DB (108 tables)
>> and writing a short test script, I really don't understand why you'd
>> want to use it over using just regular DBI and SQL. Maybe it's
>> because I knew SQL before I knew Perl and I'm training in looking at
>> things in a SQL way, but I'm not so sure. 
>> 
>> So I'd like to throw the floor open to discussion. Why would you
>> want to use DBIx::Class (or any Object-Relational Manager) instead
>> of writing classes that call the DB directly through DBI?
> 
> There's nothing about an ORM that requires that it also be an SQL
> generator.  The SQL generator is a ubiquitous and separate feature of
> ORMs, written for the benefit, for lack of a better word, of people
> who hate and fear SQL, and don't want to be reminded that they're
> using it.
> 
> You can still use the mapper, which is what ORM (Object-Relational
> Mapper) actually means, without using the SQL generator, at least in
> the good ORMs.
> 
> Cheers,
> David.
> -- 
> David Fetter <david at fetter.org> http://fetter.org/
> Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
> Skype: davidfetter      XMPP: david.fetter at gmail.com
> iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics
> 
> Remember to vote!
> Consider donating to Postgres: http://www.postgresql.org/about/donate
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm



More information about the SanFrancisco-pm mailing list