WordPress database and table structure

WordPress uses a MySQL database. As a developer, it is necessary for us to master the basic structure of the WordPress database and use them in our own plugins or themes.

As of WordPress 3.0, WordPress has the following 11 tables. The default table prefix wp_ is added here.

wp_commentmeta: store comment metadata
wp_comments: store comments
wp_links: store friendship links (Blogroll)
wp_options: store WordPress system options and plugins, theme configuration
wp_postmeta: store metadata for articles (including pages, uploaded files, revisions)
wp_posts: store articles (Including pages, uploaded files, revisions)
wp_terms: store each directory, label
wp_term_relationships: store each article, link and the relationship of the corresponding category
wp_term_taxonomy: store each category, label corresponding to the category
wp_usermeta: store the user's metadata
wp_users : store users

In the WordPress database structure, the wp_options table for storing system options and plug-in configuration is a relatively independent structure. As mentioned later, it uses key-value mode storage. The advantage of this is that it is easy to expand, and each plug-in can Easily store your own configurations here.

post, comment, and user are the combination of three basic tables plus extended tables. Take wp_users as an example, wp_users has stored the basic information that each user will use, such as login_name, display_name, password, email and other commonly used information, but if we want to store some infrequently used data, the best way is not to store in Add a column after the table to destroy the default table structure, but store the data in wp_usermeta. The extended table wp_usermeta has a similar structure to the wp_options table, where we can store each user's QQ number, mobile phone number, theme options for logging in to the WordPress background, and so on.

What is more difficult to understand is term, namely wp_terms, wp_term_relationships, wp_term_taxonomy. In the WordPress system, our common classifications include article classification, link classification, and actually TAG, which is also a special classification method, and we can even create our own classification methods. WordPress records all classifications, classification methods, and corresponding structures in these three tables. wp_terms records the name and basic information of each category. For example, this site is divided into "WordPress development", "WPCEO plug-in", etc. The categories here refer to categories in a broad sense, so each TAG is also a "category". wp_term_taxonomy records the classification method that each category belongs to, such as "WordPress development" and "WPCEO plug-in" are article categories (category), and the categories of "My Friends" and "My Colleagues" that place friendship links belong to the category of friendship links ( 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 relatively clear, so we don't need to worry about its structure.

 

 

We have introduced the role of each table in the WordPress database above, and this article will continue to introduce the role of each column in each table. WordPress official documents already have more detailed tables, this article only introduces commonly used data.

wp_commentmeta
meta_id:自增唯一ID
comment_id:对应评论ID
meta_key:键名
meta_value:键值

 


wp_comments
comment_ID:自增唯一ID
comment_post_ID:对应文章ID
comment_author:评论者
comment_author_email:评论者邮箱
comment_author_url:评论者网址
comment_author_IP:评论者IP
comment_date:评论时间
comment_date_gmt:评论时间(GMT+0时间)
comment_content:评论正文
comment_karma:未知
comment_approved:评论是否被批准
comment_agent:评论者的USER AGENT
comment_type:评论类型(pingback/普通)
comment_parent:父评论ID
user_id:评论者用户ID(不一定存在)


wp_links
link_id:自增唯一ID
link_url:链接URL
link_name:链接标题
link_image:链接图片
link_target:链接打开方式
link_description:链接描述
link_visible:是否可见(Y/N)
link_owner:添加者用户ID
link_rating:评分等级
link_updated:未知
link_rel:XFN关系
link_notes:XFN注释
link_rss:链接RSS地址


wp_options
option_id:自增唯一ID
blog_id:博客ID,用于多用户博客,默认0
option_name:键名
option_value:键值
autoload:在WordPress载入时自动载入(yes/no)


wp_postmeta
meta_id:自增唯一ID
post_id:对应文章ID
meta_key:键名
meta_value:键值


wp_posts
ID:自增唯一ID
post_author:对应作者ID
post_date:发布时间
post_date_gmt:发布时间(GMT+0时间)
post_content:正文
post_title:标题
post_excerpt:摘录
post_status:文章状态(publish/auto-draft/inherit等)
comment_status:评论状态(open/closed)
ping_status:PING状态(open/closed)
post_password:文章密码
post_name:文章缩略名
to_ping:未知
pinged:已经PING过的链接
post_modified:修改时间
post_modified_gmt:修改时间(GMT+0时间)
post_content_filtered:未知
post_parent:父文章,主要用于PAGE
guid:未知
menu_order:排序ID
post_type:文章类型(post/page等)
post_mime_type:MIME类型
comment_count:评论总数


wp_terms
term_id:分类ID
name:分类名
slug:缩略名
term_group:未知


wp_term_relationships
object_id:对应文章ID/链接ID
term_taxonomy_id:对应分类方法ID
term_order:排序


wp_term_taxonomy
term_taxonomy_id:分类方法ID
term_id:taxonomy:分类方法(category/post_tag)
description:未知
parent:所属父分类方法ID
count:文章数统计


wp_usermeta
umeta_id:自增唯一ID
user_id:对应用户ID
meta_key:键名
meta_value:键值


wp_users
ID:自增唯一ID
user_login:登录名
user_pass:密码
user_nicename:昵称
user_email:Email
user_url:网址
user_registered:注册时间
user_activation_key:激活码
user_status:用户状态

display_name:显示名称

转自 http://blog.csdn.net/ppiao1970hank/article/details/6301812

PS:本新手对元数据的理解是自定义的字段。

Guess you like

Origin blog.csdn.net/cscj2010/article/details/40655665