Certified Wordpress Developer Database and WP tables

Database and WP tables

The following is an outline and description of the database tables created during the standard installation of WordPress Version 3.4. Currently, the only database supported by WordPress is MySQL version 5.0.15 or greater.

Also see prior versions of Database Descriptions for WordPress 1.5, WordPress 2.0, WordPress 2.2, WordPress 2.3, WordPress 2.5, WordPress 2.7, WordPress 2.8, WordPress 2.9, and WordPress 3.3.

Because WordPress interfaces with this database by itself, you as an end user, shouldn't have to worry much about its structure. If you're Writing a Plugin however, you may be interested in learning how WordPress stores its data and relationships. If you have already attempted to use the existing WordPress API to access the data you need but have determined it's not possible without accessing the database directly, WordPress provides the wpdb class to make this task easy.


Database Diagram

The diagram below provides a visual overview of the WordPress database and the relations between the tables created during the WordPress standard installation. The Table Overview below includes additional details on the tables and columns.

(WP 3.0 Database diagram)

Please note that within the standard installation of WordPress no integrity between the tables is enforced e.g. between posts and comments. If you are creating a plugin or extension that manipulates the WordPress database, your code should do the housekeeping so that no orphan records remain in the tables e.g. by removing records in other tables with a set of SQL commands when foreign keys are deleted (Don't forget to remind users to backup before such operations).


Table Overview

This section is the overview of all the tables created during the WordPress standard installation. It is followed by specific information of what is in each table.

 For Support
WordPress 3.4 Tables (11)
Table Name Description Relevant Area(s) of WordPress User Interface
wp_commentmeta Each comment features information called the meta data and it is stored in the wp_commentmeta.
wp_comments The comments within WordPress are stored in the wp_comments table.
wp_links The wp_links holds information related to the links entered into the Links feature of WordPress.
wp_options The Options set under the Administration > Settings panel are stored in the wp_options table. See Option Reference for option_nameand default values.
wp_postmeta Each post features information called the meta data and it is stored in the wp_postmeta. Some plugins may add their own information to this table.
wp_posts The core of the WordPress data is the posts. It is stored in the wp_posts table. Also Pages and navigation menu items are stored in this table.
wp_terms The categories for both posts and links and the tags for posts are found within the wp_terms table.