Here is an idea(You might have to change your database structure, but it makes things a lot easier):
Let's say you have these two tables:
PROJECT
- project_id
- description
BUGS
- bug_id
- project_id //this is the foreign key the associates this bug with a project
- description
Now, you want to delete a project and all bugs associated with the project.
All you need to know is the project_id of the project you want to delete.
Then you run two delete queries.
DELETE FROM BUGS WHERE project_id = '$project_id';
DELETE FROM PROJECT WHERE project_id = '$project_id';
You could have an infinite number of tables that contain some kind of bug related information(like bug_followup or whatever) just include a project_id field in each to associate it with that project. Then you have a generic delete query where you just switch out the table name. You could make a function that took a table name as an argument if you didn't feel like writing the full delete query string and then the actually query function(mysql_query($sql)) everytime.
Does this answer your question?