Detailed analysis of WordPress databases and table structures

Source: Internet
Author: User
Tags ping link wordpress database
WordPress uses the MySQL database. As a developer, we need to master the basic structure of the WordPress database and use them in our own plug-ins or themes. As of WordPress3.0, WordPress has the following 11 tables. The default table prefix & nbsp; wp _ & nbsp; is added here ;. Wp_commentmeta: Number of comment elements

WordPress uses the MySQL database. As a developer, we need to master the basic structure of the WordPress database and use them in our own plug-ins or themes.

As of WordPress3.0, WordPress has the following 11 tables. What is the default table prefix? Wp _?.

Wp_commentmeta: stores the metadata of comments.

Wp_comments: Store comments

Wp_links: Blogroll)

Wp_options: stores WordPress system options, plug-ins, and topic configurations.

Wp_postmeta: stores the metadata of an article (including pages, uploaded files, and revisions ).

Wp_posts: stores articles (including pages, uploaded files, and revisions)

Wp_terms: stores each directory and tag

Wp_term_relationships: stores the relationship between each article, link, and corresponding category.

Wp_term_taxonomy: stores the categories corresponding to each directory and tag.

Wp_usermeta: stores user metadata.

Wp_users: storage User

In the WordPress database structure, the wp_options table in the storage system options and plug-in configuration is relatively independent. as mentioned later, it adopts the key-value mode for storage, the advantage of doing so is that it is easy to expand, and various plug-ins can easily store their own configurations here.

Post, comment, and user are the combination of three basic tables and extended tables. Taking wp_users as an example, wp_users has stored the basic information that each user will use, such as common information such as login_name, display_name, password, and email. However, if we want to store some infrequently used data, the best practice is not to add a column after the table to destroy the default table structure, but to store data in wp_usermeta. The wp_usermeta extension table has a similar structure as the wp_options table. we can store QQ numbers, mobile phone numbers, and theme options for logging on to the WordPress background for each user.

It is hard to understand the term, that is, wp_terms, wp_term_relationships, and wp_term_taxonomy. In WordPress systems, we often classify articles, links, and tags. it is also a special classification method, we can even create our own classification methods. WordPress records all categories, classification methods, and corresponding structures in these three tables. Wp_terms records the names and basic information of each category. for example, this site is divided into "WordPress development" and "WPCEO plug-in". the category here refers to the classification in a broad sense, therefore, each TAG is also a "classification ". Wp_term_taxonomy records the classification methods of each category. for example, "WordPress development" and "WPCEO plug-in" are document categories ), the "my friends" and "my colleagues" categories that place links belong to the link category (link_category ). Wp_term_relationships records the classification method corresponding to each article (or link.

Fortunately, regarding the use of term, the use of related functions in WordPress is clear and clear, so we don't have to worry about its construction.

In the above section, we have introduced the functions of each table in the WordPress database. This article will continue to introduce the functions of each column in each table. WordPress official documentation has a detailed table. This article only introduces common data.

Wp_commentmeta

Meta_id: Unique auto-increment ID

Comment_id: comment ID

Meta_key: key name

Meta_value: key value

Wp_comments

Comment_ID: Auto-increment unique ID

Comment_post_ID: Document ID

Comment_author: Reviewer

Comment_author_email: reviewer's email

Comment_author_url: reviewer URL

Comment_author_IP: comment_author_IP

Comment_date: comment time

Comment_date_gmt: comment Time (GMT + 0 time)

Comment_content: comment body

Comment_karma: unknown

Comment_approved: whether the comment is approved

Comment_agent: reviewer's USER AGENT

Comment_type: comment type (pingback/normal)

Comment_parent: parent comment ID

User_id: reviewer user ID (not necessarily exists)

Wp_links

Link_id: Auto-increment unique ID

Link_url: link URL

Link_name: link title

Link_image: link Image

Link_target: link opening method

Link_description: link description

Link_visible: visible (Y/N)

Link_owner: the user ID of the adder.

Link_rating: Rating

Link_updated: unknown

Link_rel: XFN relationship

Link_notes: XFN annotation

Link_rss: link RSS address

Wp_options

Option_id: Auto-increment unique ID

Blog_id: blog ID, used for multi-user blogs. the default value is 0.

Option_name: key name

Option_value: key value

Autoload: automatically loaded during WordPress loading (yes/no)

Wp_postmeta

Meta_id: Unique auto-increment ID

Post_id: Document ID

Meta_key: key name

Meta_value: key value

Wp_posts

ID: Auto-increment unique ID

Post_author: corresponding author ID

Post_date: release time

Post_date_gmt: Release Time (GMT + 0)

Post_content: Body

Post_title: title

Post_excerpt: Excerpt

Post_status: Article status (publish/auto-draft/inherit)

Comment_status: comment status (open/closed)

Ping_status: PING status (open/closed)

Post_password: password of the document

Post_name: name of the article

To_ping: unknown

Pinged: the PING link.

Post_modified: modification time

Post_modified_gmt: modification time (GMT + 0 time)

Post_content_filtered: unknown

Post_parent: parent document, mainly used for PAGE

Guid: unknown

Menu_order: sorting ID

Post_type: Document Type (post/page, etc)

Post_mime_type: MIME type

Comment_count: total number of comments

Wp_terms

Term_id: Category ID

Name: category name

Slug: scaling name

Term_group: unknown

Wp_term_relationships

Object_id: Document ID/link ID

Term_taxonomy_id: ID of the corresponding classification method

Term_order: Sorting

Wp_term_taxonomy

Term_taxonomy_id: category method ID

Term_id: taxonomy: classification method (category/post_tag)

Description: unknown

Parent: parent category method ID

Count: Number of articles

Wp_usermeta

Umeta_id: Unique ID of auto-increment

User_id: corresponding user ID

Meta_key: key name

Meta_value: key value

Wp_users

ID: Auto-increment unique ID

User_login: login name

User_pass: password

User_nicename: Nickname

User_email: Email

User_url: URL

User_registered: registration time

User_activation_key: activation code

User_status: user status

Display_name: Display name

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.