In order to remove thousands of old taxonomies and terms used during development, I recommended the following SQL queries to another dev:
TRUNCATE wp_terms; TRUNCATE wp_termmeta; TRUNCATE wp_term_taxonomy; TRUNCATE wp_term_relationships;
The dev told me that after he ran these queries he had a myriad of problem and other data being deleted. Other than terms and taxonomies, what other data might be stored in those tables? We know that non-post related information is stored in
wp_posts, such as Navigation Menus. In a similar vein, are non-terms data stored in the above-mentioned tables?
EDIT: Note that one can read the table structures to see exactly what obvious data is being stored, which all seems related to the Terms, Taxonomies, and their metadata and relations. This question is asking what non-obvious data may be stored in those tables as well, i.e. if they were to be truncated what data not related to Terms or Taxonomies would be lost. This is in a similar vein to loosing Navigation Menu configurations when truncating
wp_posts, which is not obvious from examining the table structure and names of
wp_posts and related tables.
There are a lot of data stored in those 4 tables
wp_terms stores the
term_group ID for a specific term.
wp_termmeta stores any meta data which you add to a term. This is a new feature introduced in WordPress 4.4
wp_term_taxonomy holds the other info of a term stored in
wp_terms. This tables stores the relationship between the term ID and other relative info such as
parent and term
wp_term_relationships stores the relationship between posts and their terms. This table just stores the
object_id (which is the post ID) and the
term_taxonomy_id (which is the term ID) and
term_order. Deleting this table will result in posts loosing their term relationships, ie, there will be no more terms associated to posts
It should be relative safe to delete the
wp_termmeta table. This should only break functions which relies on this term meta data at worst. Deleting ANY of the other three tables will break terms and any relationships they might have to posts. It is really not a clever idea to delete tables blindingly.
This question is asking what non-obvious data may be stored in those tables as well
wp_termmeta and apart from storing term data and the post ID’s to which those terms are connected to, there should not be any non-relevant, non-obvious data stored in these tables by default. Some plugins might introduce some extra columns to store additional data related to terms, but this is as far as it should go. WorPress itself does not store any additional data from anywhere in these tables
What is obvious though, if you delete these tables, any function/class/code which relies on this data will be broken