in reply to
How to structure applications using a RDBMS
Personally I like to define logical operations on the data, write perl subroutines that map to these operations, and then do whatever database manipulation that needs to happen from these subroutines.
As most of my work is with Sybase databases there is often a one-to-one mapping between these logical operations and a Sybase stored procedure, in which case there is no explicit SQL code in the application - only a call to a stored procedure, which adds an additional layer of abstraction.
This may not be the best solution in all cases, but it's what I've found easiest to maintain.