Which version of MySQL are you using? Transactions have been around for a while. What I think you need more than anything though is a foreign key constraint. Check out the InnoDB storage engine for MySQL.
-- More people are killed every year by pigs than by sharks, which shows you how good we are at evaluating risk. -- Bruce Schneier