Saltar al contenido

Database Structure in WordPress

febrero 2, 2020

 

If you manage a WordPress web site may at some time have done any related operation the database, either to make a backup, to force change a password or simply to inspect the tables.

In this article we will look generally the structure of the database and its main WordPress relationships between tables.

Table of Contents

  • What is a database?
  • What are tables and fields in a database?
  • Tables database WordPress
  • Option Table General
  • Tables metadata wp_comments wp_commentmeta wp_users wp_usermeta wp_posts wp_postmeta wp_terms wp_termmeta
  • wp_comments
  • wp_commentmeta
  • wp_users
  • wp_usermeta
  • wp_posts
  • wp_postmeta
  • wp_terms
  • wp_termmeta
  • Tables of contents with taxonomies wp_term_taxonomy wp_term_relationship
  • wp_term_taxonomy
  • wp_term_relationship
  • explanatory video
  • Conclusion
  • wp_comments
  • wp_commentmeta
  • wp_users
  • wp_usermeta
  • wp_posts
  • wp_postmeta
  • wp_terms
  • wp_termmeta
  • wp_term_taxonomy
  • wp_term_relationship

What is a database?

A database can understand it as a warehouse where data is stored in an organized manner for later use .

usually is controlled by software that helps with the administration, in the case of WordPress, it is common to use MySQL as software for managing the database.

often think that WordPress content is in HTML files, however most of the content of the posts, pages, comments, etc. They are stored in a database.

In the next picture we see that on the side of the file server have PHP dynamically create the content, retrieving it from the database and display the results in HTML files to the user.

What are tables and fields in a database?

The database is organized into tables , which in turn have fields.

We can understand this as an excel spreadsheet, where the individual sheets would be the tables and columns fields, as we see in the following image:

there is a field that is known as the identifier or ID . This field must be unique for each record and we usually used to relate tables.

Tables database WordPress

WordPress has 12 tables , although the only practice we use 11 the missing table is the wp_links table and is used for compatibility with previous versions because some plugins old still They use.

In the next picture we see tables in WordPress database and relationships:

As we can see the name of each table begins with the prefix wp_: is the default prefix, but can be changed at the time of installation of WordPress.

table

General Options The following picture shows a table that is completely isolated from the rest, meaning it has no relationship.

This table is the table wp_options and stored therein WordPress general settings and also stores the settings some plugins .

The table structure is quite simple, has fields: option_key and option_value to store data.

Some data stored in this table are, for example, the name of the subject Currently, the site name, url of the site, etc.

metadata tables

There are tables that have additional associated metadata or data, you can see in the following image attached.

As you can see a table of metadata include the name of the base table more meta prefix, for example wp_users and wp_usersmeta.

All these meta tables wp_options have a similar structure, but in this case, lead by meta_key fields and meta_value name. This way you can add as records additional fields .

Next we have the tables with associated metadata tables:

wp_comments

This table WordPress comments are stored. Some important fields include email, url and name of the author of the commentary also monitoring information such as IP, browser information and dates.

wp_commentmeta

This table adds additional data to comments. The structure includes key fields and value are commonly used by additional plugins like Akismet to mark a comment as spam.

wp_users

This table is stored the user information of the site, you have fields such as login, mail, password (which is encrypted).

wp_usermeta

This table additional information the user, such as name, last name, role, and other preferences that have configured stored.

wp_posts

Here is saved the entire contents of our website. Each record stores a type of post, for example, posts, pages, menus, and other attachments created by plugins.

has fields such as title, content, status, type.

wp_postmeta

additional information in this table is stored for each publication or recorded content. It has the structure of key and value so that you can associate many more fields to a particular record content.

wp_terms

This table names taxonomies are using different types of content, for example, are stored: category name, tag names, etc.

wp_termmeta

This table additional information for each name wp_terms taxonomy table is stored.

Tables content taxonomies

whole content of the different types of content (posts, pages, attachments, etc.) are stored in the table wp_content.

However, this content is grouped by WordPress taxonomies (categories, tags, menus, etc.). In the next picture we see the tables that are related to content and taxonomies.

tables linking content with the name of taxonomy are:

wp_term_taxonomy

this table stores the type of taxonomy to which is associated a record of the wp_terms table, for example if we have news wp_terms wp_term_taxonomy, specify that it is a category type.

wp_term_relationship

This table serves to link taxonomy or taxonomies to the which is connected a record of content, for example, an entry may be associated with one or more categories and have one or more labels.

The following picture shows an example with dummy IDs of a relationship between the content of an entry and its different taxonomies.

In the picture we see an entry called «Hello World» through the observed relationships assigned to a category (category) called blog and label (tag) named greeting. Explanatory video

Conclusion As we have been able to review, WordPress stores content of your website in tables.

Most of them maintains relationships with metadata and the table of contents has a ratio of taxonomies. Knowing this helps us have a better understanding of how stores information a website in WordPress .