Re: Databases as objects

From: Thomas Gagne <tgagne_at_wide-open-west.com>
Date: Fri, 22 Dec 2006 07:21:38 -0500
Message-ID: <haOdndMzUp1WUBbYnZ2dnUVZ_v-tnZ2d_at_wideopenwest.com>


Marshall wrote:
> On Dec 21, 1:33 pm, Thomas Gagne <tga..._at_wide-open-west.com> wrote:
>
>> ... the
>> database is an object, which should hide its data and only be used
>> through its interface, just like they do with other objects in their
>> models.
>>
>
> The interface to the database is the schema and SQL.
> What do you think the interface is?
>
After I've created a database for my application's data (let's pretend its a bookstore) I can either talk to it with low-level DML from applications

    INSERT (title, author)
    VALUES ("Complexity", "M. Mitchel")
    INTO catalog

Or I can create a higher-level interface that knows something about my bookstore

    exec p_addBook _at_title="Complexity", @author="M. Mitchel"

Additionally, I can ask the database to give me a list of its procedures (its interface), but without them all I have is its tables. True, I can tell a lot from the tables and a nice diagram, but I can tell a lot more from a list of procedures and their arguments.

That list of procedures is the interface I'm talking about. After populating a database with tables, views, and triggers, why keep talking to it using SQL when I can improve my application's interface to it by creating a domain-aware interface with intention revealing named procedures?

True, I can do everything in SQL that I can do in procedures (they're written in SQL after all), but the procedures have an improved interface and protect the integrity of my model. I could also write whatever bytecodes SQL is compiled into rather than SQL, but SQL is an improved interface and protects the integrity of the relational engine. I could even access the database's data directly on disk, but SQL is an improved interface over the bytecodes which are improved over doing my IO.

-- 
Visit <http://blogs.instreamfinancial.com/anything.php> 
to read my rants on technology and the finance industry.
Received on Fri Dec 22 2006 - 13:21:38 CET

Original text of this message