WordPress MySQL Database Management
This document will show you an outline of and describe the database tables which are created when you install WordPress Version 3.0. WordPress only supports MySQL databases which have a version of 4.1.2 or higher. As WordPress automatically communicates with the database, most end users will not need to pay much attention to its internal database structure.
However, if you are curious or making a plugin for WordPress, you may want to learn exactly how WordPress stores data and about the relationships with different databases. In the event that you have tried using the WordPress Application Programming Interface (API) to gain access to data but found it impossible without getting direct database access, we have provided the wpdb Class that will make this job possible and quite simple to do.
Diagram of the WordPress database
Here you will see a diagram which provides you with a look at the WordPress database and the relations which are automatically created between tables when you perform a standard installation of the WordPress software. We have also provided an overview which shows some more details on each table and column.
It is important to know that when you do a standard installation of WordPress, there is no integrity verification that is done between different tables, such as between comments and posts. If the plugin that you are designing makes changes to the WordPress database structure, the code within your plugin should automatically check that no records get orphaned in the tables. This can be accomplished by coding SQL commands that will remove records in the relevant tables when certain keys are removed. It is important to perform a complete backup of the database in order to prevent data loss when this operation takes place.
Tables used by WordPress version 3.0
Description: Every comment entered on your site contains meta data which is stored in the table wp_commentmeta
Description: This table contains all the comments which have been entered on your blog.
Description: The table wp_links contains all data relevant to the links which were entered in the “Links” section of the administration panel.
Description: All the options that you have set by using the “Settings” portion of the administration panel are stored in this table.
Description: Every post entered has meta data and is stored in the wp_postmeta table. There are certain plugins which add additional information into the wp_postmeta table.
Description: The majority of the content of your site will be based on posts, which are all stored in this table.
Description: Both posts and links can be put under different categories. Posts may also have tags attached to them. These will be stored in the wp_terms table.
Description: When a post is made it is associated with tags and categories that are stored in the wp_terms table. The table wp_terms_relationships stores these associations as well as those of links.
Description: The purpose of this table is to describe entries in the wp_terms table, in order to identify them as categories, links or tags.
Description: The wp_users table contains the lists of users for your site.
Description: Each “user” entry that is stored in the wp_users table contains meta data, which is then stored in the wp_usermeta table.
Changes that are made via the administration panels are stored in one of these tables. For example, when you create a new user in the “Users” panel, the data that you enter will be stored under the “wp_users” and “wp_usermeta” database tables.