[thesite] last 5 query

jeff jeff at members.evolt.org
Sun Nov 26 21:21:56 CST 2000


: From: Dean Mah
: I tend to stay away from triggers.  I like to try to separate
: the business logic, database layer, and the presentation
: layer.  Mixing them usually makes debugging the application
: more difficult.

try to think of triggers as event handlers.  you're doing the same thing
when using constraints and foreign keys.  you're initiating an action (be it
an update, delete, etc) whenever another action occurs.

the unfortunate side effect of keeping the separation you're talking about
is an increase of code in the business logic side adding to an increase in
potential coding errors as well as more convoluted logic.  on top of that,
the business logic is a much bigger hit to the system than a trigger which
resides at the same level as the data it's interacting with.

: However, if you want to implement something like this, it
: would be relatively simple.  You could write a PL/SQL or
: Java stored procedure to handle it.

i agree.  however, i think there's an even better approach to this issue.
rather than having a "last 5" table, why not just have a "last 5" file
that's altered whenever there's an insert into the database.  that way
you're off-loading all the performance hit from the front-end (including the
database hit to get the last 5 from a "last 5" table).  all the system has
to do is then include a file - a very minimal hit comparatively.

just my 2c,


mailto:jeff at members.evolt.org

More information about the thesite mailing list