Print

The WordPress Database Structure

WordPress and nearly all plugins store its settings in a special location named database. Data stored in that database is organized in so called ‘tables’.

Imagine something like an excel sheet with one header line and values in the fields below.

You can see here a small section of the table wp_options:

WordPress Database Header

Let’s talk about those tables to understand why it is important to know which table is responsible for content in a WordPress site.

Understanding the table structure will help you to understand which table you need to include or exclude if you are planning to sync or move data from a staging site to the live site or vice versa with WP Staging. It’s also helpful if you plan to update the staging site.

The WordPress Core Tables are

Other tables in a WordPress database are created by other plugins and are not necessarily needed to run successfully the website.

wp_options

The wp_options table is one of the most important WordPress database table and stores all the settings of a WordPress site like the URL, the title, installed plugins, etc. Most of the plugins store settings in this table as well.

All settings that you see in the WordPress dashboard are stored in this table.

wp_users,
wp_usermeta

wp_users stores all the registered users on a WordPress site. It contains basic information of a user like username and encrypted password, email, time of registration, display name, status and a few more fields.

wp_usermeta stores the meta data (‘information about other data‘) of the users. It extends the table wp_users with more data. For example, the first_name of a user is saved in the wp_usermeta table instead in the wp_users table.

There are two important fields in this table. Plugins can store custom data in wp_usermeta by just adding new meta_key values.

wp_posts,
wp_postmeta

wp_posts table stores all content related data of a WordPress website. All posts, pages, their revisions are available in the wp_posts table.  It might be confusing but WordPress stores much more into that table.

This table also contains navigation menu items, media files and attachments like images and content data that is used by plugins.

In wp_posts is a table column named post_type which segments that kind of different data so that specific type of data can be requested by a database query. post_type is the most important column in this table.

In the images below you can see two different post_types, revision and attachment which are stored in the same wp_posts table:

attachment post_type revision post_type

The table wp_postmeta, just like the table wp_usermeta, extends the table wp_posts with more data and can be used by other plugins as well.

For instances, social sharing plugins like MashShare are storing the share count for a particular post in this table and the Yoast SEO plugin is storing custom open graph tags, posts and url data there as well.

wp_terms,
wp_term_relationships,
wp_term_taxonomy

The table wp_terms stores Categories and tags for posts, pages and links. One of the columns in this table is ‘slug ‘. A slug is a term  that reflects a tag of a particular post. In WordPress you can use tags to connect posts, pages and links between each other.

wp_term_relationship is the conjunction and connects these tags to posts, pages and links. It’s like a map between the terms objects and the terms.

wp_term_taxonomy extends the table wp_terms with more data. It’s like meta data for the table wp_terms with the difference that another plugin can not add custom data here.

wp_comments,
wp_commentmeta

wp_comments stores comments on posts and pages. This table also contains unapproved comments and author information together with the hierarchy of comments. The table wp_commentmeta contains further meta data about the comments.

wp_links

This table contains information about custom links added to your site. It has been deprecated and is not used any longer. There are a few older plugins which still make use of it but usually it is an empty table.

Graphical Structure of WordPress Database

This diagram shows how the WordPress tables are connected to each other:WordPress Database Structure and tables

Source: WordPress.org