cap97, that's what I'm doing now; but that gets to be an awful lot of recursive deletes. 'course' is one big object, and I have a lot of delete methods that call other delete methods depending on where they are in the hierarchy. Problem is, I didn't have the foresight to build the delete methods while I had my relations mapped out and in front of me. (phpMyAdmin's PDF ability might have been real handy for that...)
What strikes me is that OOP may not be the most efficient way to accomplish recursive deletes-- and if I forget to delete a dependant record, the database just happily lets me make orphans. That doesn't seem right.
Another problem is that not every table has 'course_id' in it, since they are in 4th normal form. sigh
sxooter, one of your previous posts is what got me thinking down this line. Triggers and stored procedures are still greek to me, but it looks like I could have the database do a lot of the checking that I'm doing manually (ie, if I delete course_id, then everything dependant upon it must be deleted too.) It sounds like cascading on delete triggers is exactly what I'm looking for. Assuming these example tables/relationships:
Course
course_id
course_name
etc
Unit
unit_id
course_id
unit_name
etc
Test
test_id
unit_id
test_title
etc
Test_section
section_id
test_id
section_name
etc
would a cascading on delete trigger allow me to just say "DELETE FROM Course WHERE course_id='1'" and have it recursively delete items in Test_section? That would be really handy in the threaded discussion...
or, would it prevent me from doing so until all the dependant records are deleted?
at any rate, I'm intrigued...