I have a taxonomy vocabulary that contains a large number (5000+) of orphaned taxonomy terms. By orphaned I mean that they refer to parent terms that no longer exist, or refer to parents who are themselves orphans (grand-orphans ?). I am not talking about unused terms.
I do not see these terms in the Drupal interface as they are no longer connected to the main hierarchy. I can however still see them in the database, and I can open them directly using the tid in the Drupal interface.
I can't bulk delete them using any module because modules get the entire tree of the vocab to delete - and they are no longer part of the tree. I think I will have to delete them manually in the database. I can delete the terms from the taxonomy_term_data and taxonomy_term_hierarchy tables:
DELETE FROM taxonomy_term_hierarchy WHERE parent NOT IN (SELECT tid FROM taxonomy_term_hierarchy) // or something like it
Are there any other tables I need to think of though, in order to not end up with a database that's messed up worse than it already is?