Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trigger query
Message
De
17/10/2013 13:59:37
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
17/10/2013 06:29:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP3
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01585722
Message ID:
01585778
Vues:
47
>I have a customer table which has 3 associated child tables; customer.custid is the primary key in customer. Custid is the the foreign key in the child tables. I have "Update" and "Delete" rules established in the RI builder.
>
>When I have the customer table open and I do a block replace such as REPLACE ALL CUSTOMER.MAILOUT WITH .F. the update trigger runs for every record - which takes a long time. I assumed the trigger would only run if the key field was being changed.
>
>Is there some way I can prevent the trigger from running as this particular update has no requirement to check the RI of child tables? Or maybe I have a fundamental misunderstanding of how this works.
>
>Barry Sutton

Hi Barry

The update trigger on the parent fires on every update of the parent if you have the update trigger.

If I understand correctly, your custid is something meaningful to your customers. So if they change the custid, you must update the child tables. However, if you made your primary key meaningless, and used that for relations (NOT CUSTID), the users could change custid as often as they want and you would not need to update the child table. All you would need is a cascade delete.

That means change your data structure for the customer table like this...

customer
customerpk, custid

childtable
childpk, cusfk. no custid.

I know some people think it's better to have content in the child table that helps you identify the record without seeing the parent table, but that's what the computer is for. A simple relation lets you see the parent table contents. Also the concept is not to repeat data inside the system. If custid is really user meaningful data, you are repeating it in the child table. Ignore the primary key and foreign keys since they are meaningless and do not repeat any user data in multiple tables.

Works great.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform