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

Home -> Community -> Usenet -> c.d.o.tools -> Re: simple trigger problem ?

Re: simple trigger problem ?

From: <rtproffitt_at_my-deja.com>
Date: 2000/05/08
Message-ID: <8f6ncn$cha$1@nnrp1.deja.com>#1/1

Norab,

It is not clear what your table relationship is.... You are saying there is a many-to-one, but what is the key? It can't be customer ID, because then you would have multiple address records... So it must be something like AddressID

   Customer, CustID, AddrID .......
   AddrID, Address, city, state, zip, etc.....

I wonder what led to this original design...? Are there so many addresses that there is a real big savings normalizing this way? Or is the size small enough that denormalizing the address (into the customer table) would give a big savings in maintenance, coding, etc.???

All of that said... here are some ideas.... (I will assume there is an AddressID field)...

  1. Create a stored function or functions which would handle all the possibilities...make a truth table: -first time cust insert, address does not exist -first time cust insert, address does exist -delete cust, address not used by others -delete cust, address used by others -update, old address no longer used, new address first time -update, ...ditto..., new address already used -update, old address still used, new first time -update, old still used, new already used. You will need a series of Select count, or cursors to gather the data you will need to answer the questions...

Once you find which condition applies, then you can easily decide what to do:

No matter what, it is not trivial....
Weigh this against changing the design of the address table, and asking yourself...was there a good purpose in the beginning for the original design...

(Comments anyone? other suggestions?)

HTH
Robert Proffitt
RTProffitt_at_Beckman.com

  "norab" <norab_at_digibel.org> wrote:
> as a project i developed a simple database with oracle designer,
 including
> application forms.
> Here is what the problem is:
>
> a table customer is linked to a table adress with a many to one
> relationship.
> when i update a customer's home adress via the form, the adress of
 other
> customers who live at the same adress is also changed.
> off course because if 3 customers live at the same adress, only one
 adress
> record will be in the adress table. and if one of those three
 customers
> change adresses, and i update that record, the two other customers
 will also
> have that changed adress.
>
> I was looking for a solution with database triggers (after update on
> adressen), but the problem is that at that point i dont know WHICH
 customer
> changed adress.
>
> Is there a solution with database triggers or any other?
> tnx for al help
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon May 08 2000 - 00:00:00 CDT

Original text of this message

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