I know WordPress stores all post data in 'wp_posts'
table. But here WordPress not define any category id or reference related with it.
Please let me know, how 'wp_posts' table find out exact category? Please explain me in details.
See the Codex's WordPress Taxonomy documentation.
WordPress 2.3 replaced the previous categories, post2cat, and link2cat tables with three a more flexible set of taxonomy tables.
wp_terms
wp_term_relationships
wp_term_taxonomy
wp_terms- holds the basic information about single terms.
term_id bigint(20) unsigned NOT NULL auto_increment,
name varchar(200) NOT NULL default '',
slug varchar(200) NOT NULL default '',
term_group bigint(10) NOT NULL default 0,
PRIMARY KEY (term_id),
UNIQUE KEY slug (slug),
KEY name (name)
wp_term_taxonomy - defines the taxonomy - either tag, category, or custom taxonomy
term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default 0,
taxonomy varchar(32) NOT NULL default '',
description longtext NOT NULL,
parent bigint(20) unsigned NOT NULL default 0,
count bigint(20) NOT NULL default 0,
PRIMARY KEY (term_taxonomy_id),
UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
KEY taxonomy (taxonomy)
wp_term_relationships - contains the many-to-many relationship between WordPress objects such as posts or links to a term_taxonomy_id from the term_taxonomy table.
object_id bigint(20) unsigned NOT NULL default 0,
term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
term_order int(11) NOT NULL default 0,
PRIMARY KEY (object_id,term_taxonomy_id),
KEY term_taxonomy_id (term_taxonomy_id)