When adding a relationship between two tables, I am offered the choice of adding triggers to the On-Update and On-Delete events of the foreign table. Now I understand that when the foreign table is deleted, the On-Delete event will be triggered in the local table.
An example of this is a user and profile in a one to one relationship. In Propel this offers some extra functions to make finding attached records simpler than querying using a foreign key. Now, I have the primary key set as a foreign key to the user table with an On-Delete trigger of CASCADE. This means that when I delete the user record, the profile record(s) gets removed as well.
Now, what would a cascading On-Update trigger do? When using propel I can change the profile properties without saving and then call save on the user, if I have cascading on-update set for profile, will it automatically save/update the profile information when saving a user?
The reason this is so confusing is because the tables don’t know about Propel, so there must be another reason for the On-Update and the Propel documentation only explains the use of the On-Delete trigger.
Any kind of insight relating to Propel would be greatly appreciated. Some generic definition is not what I am looking for.
Unless things have changed since 1.2 these are simply implementations (either native or emmulated) for tradidional RDBMS constraints (mysql 5.5 constraints docs). This has nothing to do with propel it has to do with databases. Thus
ON UPDATEwould allow you to CASCADE the updated key value – this assumes you have FK’s where the value can change. It doesnt have anything to do with other columns.It will do this even if you dont have
CASCADEturned on as long as the related object is hydrated on the object you issue the save to. TheON UPDATEstuff has nothing to do with this, its the mere fact that the two carry a relationship and thus have object members in each class that allows for this. When you call save on an object, it goes through all hydrated objects and collections and saves anything that is marked as changed.