Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Is triggers really necessary ?

Re: Is triggers really necessary ?

From: Tomm Carr <tommcatt_at_geocities.com>
Date: 1997/07/30
Message-ID: <33DFCC29.956@geocities.com>#1/1

Terrence Wong wrote:
>
> Gurus, experts, experienced users...

You called? Between my cube-mate and myself, we know all there is to know about triggers.

> (1) Are there examples of implementation of triggers in a web
> environments.

My cube-mate knows this one...

> (2) When do we use triggers, eg. cascading deletes etc. ?

You can use triggers to perform cascade deletes or respond to cascade deletes in some manner. Generally, you use triggers when you need to enforce business rules that are more complicated than the simple integrity checks performed by the DBMS (not null, a > b, etc.). For instance:

"When a new invoice is created, the delivery will be scheduled for 9:00 AM the following day for orders received before noon and 5:00 PM the following day for orders received after noon. Except when the order is received on a Friday, in which case the delivery will be scheduled for 9:00 AM the following Monday."

A rule such as this can only be enforced thru code. But where to put the code? If you are absolutley sure, beyond a shadow of a doubt, that the *only* access to the table will be thru your *one* application -- you can place it there. Otherwise, I would strongly urge a trigger.

Another common use of triggers is to maintain activity logs -- this user changed this data on this date.

> (3) Is maintaing triggers difficult, if the underlying structure of the
> programs need changing ?

Triggers are no more difficult to maintain then any other code you write. The nice thing about triggers is that a well designed trigger will not have to be changed in response to your programs. Changes to the underlying data structure, sure -- but not (normally) your application code.

> (4) Impact on performance within the web environment using triggers.

I can't speak definitively for a web environment, but I can't see how it would be all that different from a client/server environment. In your consideration of to trigger or not to trigger, performance should be dead last on your list. I won't say there is *no* performance hit, but it will probably be less than whatever you use instead.

> (5) Lastly, is triggers neccessary ?

Like oxygen, food, beer? No, you can get along without triggers. But they can make your entire system, especially security and business rule enforcement, a *whole* lot easier to design, maintain and operate.

-- 
Tomm Carr
--
"Can you describe your assailant?"
"No problem, Officer.  That's exactly what I was doing when he hit me!"
Received on Wed Jul 30 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US