From: Phillip Gawlowski Date: 2010-11-13T22:35:00+09:00 Subject: Re: ORM's - Don't Do It! On Sat, Nov 13, 2010 at 10:54 AM, Mike Stephens wrote: > My problem is the mismatch. > > Objects have data that relates to what they are doing and can be > configured to suit their needs. > > The database approach views data as having an innate structure created > by many different stakeholders, use cases, and therefore many different > potential objects. In other words: Databases contain data that relates to what the DBs are doing, and that can be configured to their needs. Essentially, the data that you store in a database, any database, has to be massaged such that you can store it in the first place. AKA normalization. > A language like SQL gives you a neat interface between the two worlds. No, it doesn't. SQL's syntax is unlike any programming language I know. Pure SQL contains no looping constructs, for example. It can only retrieve and store data. > It is trivial to adjust an SQL call wrapper even if you need to. Any > minor extra burden on connecting from your Ruby program is more than > compensated by the  more sophisticated (more precise) representations of > the data and the wealth of other database tools and services (stored > procedures, triggers etc) made available to you. In how far is SQL's representation of data "more sophisticated"? In the end, the rows returned by an SQL query are nothing but an Array (maybe a Hash with the SQL query as a key in Ruby parlance). Since Triggers operate on the SQL statements, which the programming language <-> SQL DB interface *has* to use (no matter if it is shelled out to the command line, uses ORM, or JDBC), you don't lose the any capabilities your SQL DBMS offers you, since those operate on the SQL statements (they have to, since you don't have to interact with a DB with its vendor-supplied driver). However, the abstraction offered by, say, ORM, allows the programmer not to have to *care* about the underlying database, so he doesn't have to care about the SQL used. Which, considering the ugliness of SQL, is no small blessing. > (Also as dog-collar wearing , fully ordained, anti-ORM preacher, it is a > matter of faith - I was just brought up to believe in these things. I > guess I'll never change) So, you aren't arguing, you are preaching. I leave the credibility of your arguments as an exercise to the reader. -- Phillip Gawlowski Though the folk I have met, (Ah, how soon!) they forget When I've moved on to some other place, There may be one or two, When I've played and passed through, Who'll remember my song or my face.