When a parent row is deleted..
For e.g, I have a table
The comments and session has a foreign key of
How would I delete the data from the child table if the data from the parent table is deleted.
In my case, how would I delete all the rows relating to user 5 in comments and sessions table when user 5 is deleted from the users table?
I am looking for a relationship method, not a query.
You'll be wanting cascading delete for that sort of stuff.
The question is if you should do a cascading delete. Just think. You have a blog, users post comments to your articles, and if an user account is removed should all his/her comments be deleted? It looks quite different for a SESSIONS table.
I'd rather them deleted than what MySpace does and puts "Account does not exist" with an avatar of a red cross next to it. I like to put a comment to a face!
Surely there are privacy issues that arise in that when a user is removed from the system they would much prefer it if everything was removed. That's part of the argument that's on-going with Facebook at the moment - something about people not being able to remove their very last picture from their account. As well as the intrusive advertising idea.
Another issue arises however. If you were to be the nice guy and remove everything relating to that user, you will undoubtedly be left with nonsensical conversations in the blog comments.
|All times are GMT. The time now is 07:49 AM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0