I have written tables in a MySQL database. There happens to be an Art table, and three related tables, Sculpture, Painting, and Photo.
Every item in Art also happens to be in one and only one of the other three. I am trying to write a trigger so that when I delete a tuple in Painting, the trigger will delete the tuple in Art which corresponds.
This should only work for Painting, and not affect either Sculpture or Photo. Every one of these items has an id_no, and there is a matching id_no in Painting for each one that is a painting. I can't just delete any id_no in Art that's not in Painting, since it may still exist in Sculpture or Photo.
So I'm not sure if I should go about this by temporarily saving the id_no somewhere (that was deleted from Painting), then doing a comparison and deleting in the trigger (from Art), or even how that would be done.
DELIMITER $ Create trigger delete_painting After delete on Painting Delete from Art WHERE