Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have constructed a DB with 10 tables on it and I want the PK which are FK in other tables to auto update upon inserting, updating, deleting data into them. do I use 'TRIGGER' or 'ON CASCADE'. How does one achieve filling in one line of one table but at the same time the FK's fill in same time?
Posted
Comments
[no name] 11-Oct-15 9:27am    
I would suggest "ON CASCADE". Keep in mind this can end in very heavy Operation in case you have "millions" of Details. Usually a good strategy would be "PRIMARY KEY" can not Change, but I know in Praxis this is sometimes hard...
John C Rayan 12-Oct-15 7:57am    
As 0x01AA mentioned , if you are changing your PK then you are doing something very wrong.

1 solution

I recommend using UPDATE CASCADE and DELETE CASCADE to maintain referential integrity. Here is a helpful resource on the topic:

https://www.mssqltips.com/sqlservertip/2743/using-delete-cascade-option-for-foreign-keys/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900