I was reading madermans post about Composing a SQL statement and I was reminded of some very peculiar software architecture I saw last year. As I started writing this I realised I had gone way offtopic, but I still wanted the monastary's opinion.

This system I was working on had introduced 'SQL abstraction layer' between the database functions layer and the database itself:

webserver
CGI layer
processing
DB functions layer
SQL abstraction layer
DBI/DBD
database

The DB functions layer defined commonly used functions like 'add_user' 'add_transaction'. Such layers are common, and they allow you to cleanly change the database backend without worrying about the front. But in this case the DB functions layer didn't directly use SQL... Instead it called from an array of new functions derived from the level below, eg:

&my_db_connection->update( table_name => $table_name, keys => &my_db_connection->select( table_name => $table_name, return_field => 'userID', select_field => 'userName', value => $username), update_field => 'userAddress', update_value => $new_address);
The select and update methods would generate and execute the SQL. I was expecting to find a more direct generation of SQL, eg:
$sql = "UPDATE users SET userAddress='$new_address' WHERE userName='$ +username'"
The only advantages of this approach (IMHO) are: Whereas the disadvantages are: And of course all of the other issues that arise simply by virtue of writing an extra 2000 lines of code

Has anyone got ANY ideas why the original developers might have done this ? ? ?

In reply to Architecture of a Database system by Boldra

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.