KBD

Keith Devens .com

Monday, March 15, 2010 Flag waving
I meant what I said, and I said what I meant. An elephant's faithful, one hundred percent! – Horton (Horton Hears a Who, Dr. Seuss)
← BubblesFunny quote about congress →

Daily link icon Sunday, March 14, 2004

O/R Mapping Tools?!

It's a travesty that "O/R mapping tools" is currently far ahead in this poll.

← BubblesFunny quote about congress →

Comments XML gif

Carlos E. Perez (http://www.manageability.org) wrote:

why not?

∴ Carlos E. Perez | 15-Mar-2004 11:42am est | http://www.manageability.org | #4124

Keith (http://keithdevens.com/) wrote:

Mainly because of leaky abstractions. As Tim Bray has said:

Lots of architects have learned, painfully, that you usually can’t magick relational rows away behind object/class abstractions. The right way to think about a database is as a set of normalized tables that are designed to be addressed with SQL strings.

Object mappings just don't map well onto relational tables. Objects have no concept of a join, for instance. On the surface, O/R mappings look extremely attractive, as they make for very elegant code examples. However, I get the feeling they're only appropriate for simple database schemas. Once you move beyond that, I can't imagine you won't hit a wall where the O/R mapping can't automatically do what you want anymore and you're going to have to speak to the database without an intermediary.

However, I (and Tim Bray, and Simon) could be wrong, and O/R mappings may work in every case and save people lots of time. But on the whole I've stayed far, far away from them, since OO and relational databases are so very different from each other. I've never bought into the idea that O/R mappings can sufficiently hide those differences and use the database efficiently.

Keith | 15-Mar-2004 3:30pm est | http://keithdevens.com/ | #4127

Moss Collum (http://www.m14m.net/) wrote:

I think it's partly just a matter of using the right tool for the right job. There are some things I do in SQL in my current project that only really make sense in SQL, so for that project, I need to have access to a real database connection. On the other hand, when I was hacking out a bug tracking system a few months back, I was basically just using the database as object storage, and didn't need to do anything more than a few simple selects and joins. I used SQLObject, and found that it did everything I needed. I could have done without it, but it would have been considerably more coding in both SQL and Python.

Of course, part of the reason I was comfortable using SQLObject is that it's fairly transparent--I can usually tell what it's doing in SQL, and it won't break if I talk to the database directly. I wonder if that can work as a general rule. It's okay to use an abstraction if you can get behind it when necessary?

∴ Moss Collum | 16-Mar-2004 4:34pm est | http://www.m14m.net/ | #4145

Christian Langreiter (http://www.langreiter.com) wrote:

Keith, object graphs and relational tables are actually almost isomorphic - foreign keys are nothing but pointers! If you want to try a truly fantastic O/R mapper, give the <a href="http://www.helma.org">Helma Object Publisher</a> a shot. I usually handle scenarios one would usually use queries for with a bunch of collections (usersByLastName, usersByAge, User.storiesByModificationDate &c.). It works great.

I have worked with Hibernate (probably the best open-source O/R mapper for Java) in a Swing context, and there it's been a mixed blessing - but for web applications the problems we encountered in a desktop application environment are usually eliminated by the rigid request/response cycle (whereas with a desktop application, the object graph can be in different states in different windows, which makes the question when to actually commit stuff &c. a tricky one).

∴ Christian Langreiter | 18-Mar-2004 8:52pm est | http://www.langreiter.com | #4176

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive

Generated in about 0.137s.

(Used 8 db queries)