KBD

Keith Devens .com

Wednesday, October 8, 2008 Flag waving
*What in our history together makes you think I'm capable of something like that?* – Owen Wilson's character in Shanghai Knights
← 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)
:

October 2008
SunMonTueWedThuFriSat
 1234
567891011
12131415161718
19202122232425
262728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

new⇒Timesheet Calculator

Hadn't seen it before now, but my​company already uses a time​tracking prog...

Keith: Oct 7, 10:44am

Girls, please don't get breast implants

Hey everyone, 

I am new to this​blog and I have enjoyed reading all​your...

Sarah.M.: Oct 6, 9:45am

obout inc - ASP.NET controls

I like there components. I've got​it to work locally on my pc.​However I'm ...

Jeff: Oct 2, 4:43pm

Dumb substring behavior in C# (and Java)

Yes, the Substring function is not​helpful when you hit the length​problem,...

Mike Irving: Oct 2, 7:56am

Generated in about 0.109s.

(Used 8 db queries)

mobile phone