http://qs321.pair.com?node_id=895586


in reply to Maybe database tables aren't such great "objects," after all ...

IMO, database abstraction is useful. But, mapping tables to Perl classes isn't any abstraction at all. It's exposing the details of your database layout to your program - quite the opposite of abstraction.

I've seen the following design a few times, and it's my favourite:


    +------+  +------+  +------+
    | App. |  | App. |  | App. |  ....
    +------+  +------+  +------+

    +----------------------------+
    | Shared application library |
    +----------------------------+

    +----------------------------+
    | Database Interface Library |
    +----------------------------+
                                                 Application
------------------------------------------------------------
                                                 Database
    +--------------+  +--------------+
    | Stored Proc. |  | Stored Proc. |  ....
    +--------------+  +--------------+

    +-------+  +-------+  +-------+
    | Table |  | Table |  | Table | ....
    +-------+  +-------+  +-------+

Each layer only talks to the layers directly above or below it. Perhaps overkill for a simple web application, and maybe not suitable for an agile environment, but the application not knowing anything about the table structure gives more freedom than one initially would think.