Monday, February 27, 2012

Best way to work with MySQL table relations (referential integrity)

Spurred into action (eventually) by Jeremy Burn's (ClassOutfit) talk at CakeFest Manchester, I have for the first time tuned my database and included referential integrity relations.  The database is now doing everything that it should be, i.e. stopping me from deleting records that would result in an orphan record.  I was just wondering how people deal with allowing records with children to be deleted (along with their children) when having MySQL relations in place.  

I assumed that if I had 'dependent' => true in my model relation that the children would be deleted and the parent could then be removed, but I keep getting dbo errors.  I hope I am missing something obvious as to have to manually check for children and delete them seems counter like I am sacrificing some of Cake's automagic when deleting records and I'm not sure if that is worth it as it was easier to have CakePHP checks in place when deleting files that children were not left on relationships if dependent was set to false.

Thanks, Paul.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: