WordPress Database Structure

WordPress by default will create some core tables in the database during installation. These tables are sufficient for WordPress to work properly. However, plugins will add additional tables to enhance the functions. For example, WooCommerce plugin will add more than 25 tables in the database. Unfortunately, most plugins including WooCommerce will not delete the database tables when deleting the plugin. This may create confusion when you look into the database about the core table and tables created by plugins. Here is the details of WordPress database structure explaining the function of each core table.

WordPress Database Structure

WordPress database will have the following 12 tables as part of default installation:

TablePurposeAdmin Panel Section
wp_postsStores contentPosts / Pages > Add New
wp_postmetaStores post meta dataPosts / Pages > Add New
wp_commentsKeep comments from usersComments
wp_commentmetaKeep comment meta dataComments
wp_termsStores categories and tagsPosts > Categories
Posts > Tags
wp_termmetaMeta data for categories and tagsPosts > Categories
Posts > Tags
wp_term_relationshipsTerm relationship with postsPosts > Categories
Posts > Tags
wp_term_taxonomyAdditional details for terms table 
wp_users User detailsUsers > Add New
wp_usermeta User meta dataUsers > Add New
wp_links Link detailsNot used
wp_optionsSite settingsSettings section

The above list of tables are for single site installation and for multi-site you will have additional tables like wp_blogs, wp_blogmeta, wp_sites, wp_sitemeta, wp_blog_versions, wp_registration_log and wp_signups. In this article, we will focus only on the single site installation.

Related:  Can I Really Make Money Online?

Any other tables in your database is created by plugins. Remember, WordPress uses “wp_” for table prefix by default. However, you may find different prefix based on the one you used during installation. Softaculous and other on-click WordPress installers will create different prefix automatically when installing WordPress through your hosting account. As you can see, the below example on our demo installation has “wpeg_” as table prefix.

WordPress Database Tables
WordPress Database Tables

Core WordPress team has a beautiful picture to explain the structure of WordPress database. It clearly explains the structure and fields used by each table.

WordPress Database Structure
WordPress Database Structure

WordPress Tables Explained

Let us start with explaining the tables based on the frontend look of a WordPress page. Below is a sample page of this site that has text, image, link and comment. The corresponding table is mentioned from where you can find the data in the backend.

Article with Relevant WordPress Tables
Article with Relevant WordPress Tables

In addition, you can find each table data under corresponding sections of WordPress admin panel as mentioned in the above table.

Posts Table: wp_posts

Many people misunderstand the meaning of posts table that it only stores posts. WordPress stores all your text content in wp_posts table regardless of post types. It means, you can find all your content in wp_posts tables for posts, pages and any other custom post types. In addition, you can also find attachments, revisions and autosave in the same table.

Post Meta: wp_postmeta

The best example of explaining post meta is with Yoast SEO plugin. When using the plugin, you can see the meta box for adding SEO title, meta description, etc. for each post. WordPress will store all these post associated data in wp_postmeta table.

Post Meta Table Structure
Post Meta Table Structure

This is one of the fast growing in many WordPress installation due to improper use of plugins. Check out our article on how to cleanup postmeta table in WordPress.  

Related:  11 CSS Image Hovering Effects for Weebly

Comments: wp_comments

If you have enabled comments in WordPress, you will see an option to leave the comment under each post or page. WordPress will store all user comments under “wp_comments” table.

Comments table is also one of the fast growing in many WordPress installation due to spam comments. You should use Akismet, captcha or any other way of moderating comments to avoid the table contains junk comments.

Comments Meta: wp_commentmeta

Similar to post meta, WordPress will store all comments meta in wp_commentmeta table.

Terms: wp_terms

Terms table stores categories and tags for the posts.

Term Meta: wp_termmeta

All term meta data is stored in wp_termmeta table.

Taxonomy: wp_term_taxonomy

It extends the details of the terms stored in wp_terms table.

Relationships: wp_term_relationships

This table stores the category and tags relationship to posts.

Users: wp_users

You can find all registered users on your site in this table. Remember, this table will not have the commenters who leave comments without registration. You have to find that details in wp_commentmeta table.

User Meta: wp_usermeta

Meta data related to users are stored in wp_usermeta table.

Links: wp_links

Earlier WordPress had an option to create links like creating new posts. However, this was removed subsequently and the table is no more used. You should see this table empty unless theme or plugin developer using it.

Options: wp_options

Options table stores all site wide settings like site URL, active plugins, admin username, etc. Plugins and theme developer often use options table to load the settings. If options table create problem for you, check out our article on how to cleanup wp_options table.

Recommended Articles:

Leave a Comment