Taxonomy Tables in WordPress

Taxonomy, terms and relationships are divided into three distinct tables to allow many-to-one relationships between these categories, tags, items in custom taxonomies, and posts. Relationships are hierarchical and multi-valued. In the wp_posts table while you could add an array of tag or category identifiers to each row, Let’s suppose, that approach puts an explicit limit on the number of descriptive relationships for each post while also wasting space allocated for tags or categories that may not be assigned.

A category if you created by the name of “Web Design Company London” then put seven posts in that category, all three taxonomy related tables are updated by this:

1.    In the wp_terms table one row defines “Web Design Company London” and its slug, or diminutive form used in URLs. A unique identifier (key) this relationship gets useful for matching the term to other tables of database.

2.  In the wp_term_taxonomy table maps define in on row “Web Design Company London” to the “category” taxonomy. A unique key this relation also gets, The combination in “category representing of “Web Design Company London”. wp_term_taxonomy table there is no different row for that mapping, along with its unique key.

3.    In the wp_term_relationships table map the “Web Design Company London in category” four rows is identifier to the post identifiers for each of the posts that are in the category. The workhorse operator in working with taxonomy tables is the SQL JOIN, it referred sometimes to as the “product” of two (or more) tables of database.
With a JOIN query it builds a temporary table with each row in one table mapped to every row in the second and successive tables; and the WHERE part of the JOIN query operation selects those rows where specific fields in each row match in this field. To find all of the posts in the “Web Design Company London in category”, First finds the identifier for this term and taxonomy pair, then selects the appropriate rows from the wp_term_relationships table of database, and then does a JOIN on the wp_posts and the selected rows from the relationships table: that last JOIN is SQL-ese for the extract all of the posts with identifiers in this list, where the list is computed on-the-fly.
Below Figure shows of the joins query as a graphical representation between the wp_posts table of wordpress and taxonomy tables in WordPress.

Graphical representation between the wp_posts table of wordpressaxonomy Tables in WordPress
Graphical representation between the wp_posts table of wordpressaxonomy Tables in WordPress

When makes the SQL query for selecting the content associated with a particular tag or category more complex, then requiring the use of a multi-table JOIN operations to implement it the “name in a taxonomy in a relationship” matching, so it is powerful in allowing the content it to be given rich and multi-valued descriptions, and for taxonomy, category and tag names to have independent name spaces between them.