|
I think you can set a foreign key in the dish table that refers to the restaurant table, with a cascading delete attached to it. However, I also think you have to use the InnoDB storage engine (dont think MyISAM supports foreign keys).
If your concern in the first place is that you don't wanna run two seperate queries in case the first one succeed and the second one fails, another alternative is to use transactions (also supported by InnoDB but not MyISAM). Transactions ensure that either all queries are successfully run, or none is. If one fails, everything is "rolled back" to their state before the transaction.
EDIT: Oh, I was too slow. I opened this tab 20 minutes ago and didn't post until now, seems I wasn't quick enough :P
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
Last edited by lizciz; 07-21-2011 at 03:59 PM..
|