Efficient Strategies for Deleting Descendant Rows
Posted: Fri Dec 16, 2011 3:37 pm
I've also asked this question here (http://stackoverflow.com/q/8540240/105539). I'm trying to look at strategies for deleting descendant rows from a single table that recursively points back to itself.
Imagine nothing but a single categories table with only:
* id
* parent_id
* category_name
The parent_id is where you point back to the id column of the categories table, but to a different row -- the parent of this category.
I want to delete a given category, but delete all its descendants (children, grandchildren, great grandchildren, etc.) as well.
Note I have PHP5, PDO, and MySQL 5.
Imagine nothing but a single categories table with only:
* id
* parent_id
* category_name
The parent_id is where you point back to the id column of the categories table, but to a different row -- the parent of this category.
I want to delete a given category, but delete all its descendants (children, grandchildren, great grandchildren, etc.) as well.
Note I have PHP5, PDO, and MySQL 5.