WordPress Database Structure and Schema
A database will be created whenever you install a WordPress site. Everything on your WordPress website will be stored in this database.
WordPress website by default contains 12 tables.
WordPress database table relationship
- wp_posts
- wp_postmeta
- wp_options
- wp_users
- wp_usermeta
- wp_term_taxonomy
- wp_terms
- wp_term_relationships
- wp_links
- wp_comments
- wp_commentmeta
- wp_termmeta
wp_posts
All content related to the WordPress website is stored in this table. Such as navigation menu, images, media files, and all attachments.
All plugins data is also stored in this table. This table also contains the text revisions and custom items.
wp_postmeta
Data about data is called metadata. wp_postmeta
is extension of wp_posts
. Some plugin data may also store in this table. Basically, it stores extra information from wp_posts
.
wp_options
wp_options
is the most important table of WordPress websites. It contains all administrative settings.
This table contains the website URL, titles, installed plugin & many more. The settings of plugins stores in this table also.
This table also stored the WordPress dashboard settings.
wp_options
the table doesn’t share the relationship with other tables.
wp_users
All registered user information stores in this table. Such as like username, password, email, display name, and registration time of the users.
wp_usermeta
wp_usermeta
is the extension of wp_users
. This table store the extra information of the wp_users
table.
wp_terms
wp_terms
contain the categories for posts and pages. It also contains the tag(slugs) for the posts. Links related to categories are also stores in this table. This table has a relationship with wp_term_taxonomy
and wp_term_relationships
.
wp_term_taxonomy
wp_term_taxonomy
stores the description of categories, tags, and certain links associated with categories.
wp_term_relationships
wp_term_relationships
helps to maintain relationships. The wp_posts
contains the post data. The wp_term_relationships table records the set category and tags.
wp_links
wp_links
contain the information about custom links added to your WordPress site. It has been deprecated and is not used any longer. Few older plugins still use. But usually, it is an empty table.
wp_comments
All comments (Approved and Unapproved) are stored in this table. This table also stores the information like author name, email, type of comment(whether it’s a simple comment and pingback/trackback).
wp_comment_meta
Extra information about the comments like which posts and pages are associated with stored here.
wp_termmeta
wp_termmeta was introduced in WordPress 4.4. This table is used to store additional info about terms. It is possible to access the term meta using the following function:
get_term-meta
, add_term_meta
, update_term_meta
, and delete_term_meta
.