WordPress Database Schema and Tables You Should Know

Ever felt like you’re deciphering an ancient map when navigating the WordPress database schema? It’s the hidden framework that organizes and stores your site’s precious cargo—your data. Think of this article as your personal compass pointing you through the intricate pathways of tables and relationships that form the backbone of any WordPress website.

At play here isn’t just any old database; it’s a masterfully crafted set-up tailored for a CMS powerhouse.

By the close of our exploration, you’ll have charted the terrain of WordPress’s MySQL heartland—from the WPDB class to query optimization.

We’ll delve into the realms of database tables, unveil the mysteries behind the WP_Posts and WP_Options, and even touch upon safeguarding treasures with database backup techniques.

Whether you’re spearheading site development or simply looking to school up, understanding this landscape is non-negotiable for peak website performance.

So buckle up, data traveler; you’re about to embark on a quest to claim mastery over WordPress’s formidable data labyrinths.


The database is an indispensable part of a WordPress site. WordPress utilizes the MySQL database management system version 5.6 or greater.

It can also use MariaDB version 10.1 or higher.  MariaDB is a fully GPL licensed fork of MySQL that works as a substitute for MySQL.

A good comprehension of the structure of the table is essential. It allows users to know which table to include or exclude when syncing or moving data from a staging site to the live site using WP Staging.

This is true for the reverse process too. It’s also useful for updating the staging site.

WordPress and the database interface automatically. This means that end-users don’t need to know about its structure.

However, for those writing a plugin, it may be beneficial to have more information. This may include how WordPress stores its data and relationships.

You may have tried to use the existing WordPress API to access the required data. It is, however, impossible without a direct connection to the database.

For that reason, WordPress provides the wpdb class.

A popular way to access the WordPress database is to use an online admin tool called phpMyAdmin. It is often pre-installed on many web hosts (via cPanel).

It is also available in local development environments such as MAMP.

Remember though that accessing the database comes with a risk. Any wrong move may break your site.

So before doing anything, it’s best to make a back-up.

Overview of the WordPress Database Schema and Tables

A brand new WordPress website has 12 tables. Those are:

  1. wp_posts
  2. wp_postmeta
  3. wp_options
  4. wp_users
  5. wp_usermeta
  6. wp_term_taxonomy
  7. wp_terms
  8. wp_term_relationships
  9. wp_links
  10. wp_comments
  11. wp_commentmeta
  12. wp_termmeta

Tables are often associated with one another since various pieces of data may be related.

For example, a blog post may be linked to categories and tags. So the table storing blog posts will relate to the table storing categories and tags.


The wp_post table stores all data related to the content of a WordPress website. This includes things such as posts, pages, and page revisions.

Also stored here are navigation menu items, media files, images, and attachments. Content data used by plugins also sit in this table.

Post_type is a table column within wp_post that categorizes the above-mentioned data. It allows users to request specific types of data using a database query.

This makes post_type the most important column in the wp_post table.

The post_type column shows the type of each row – a post, page, attachment, nav_menu_item, or another type. This variety of content gives the table a flexible nature.


Every post contains a set of data called metadata. Storage of this information takes place in the wp_postmeta table.

Certain plugins may also add their data to this table.

wp_postmeta is an adjunct to the wp_post table. It is a vertical table that stores the data using key/value pairs.

This is a technique many WordPress tables use. It enables WordPress core, plugins, and themes to store unlimited data.

Mashshare, a social sharing plugin, also uses this table to share counts of specific posts.

Note: Many database tables allow WordPress core, plugins, or themes to store additional information.


wp_options is one of the most important WordPress tables. This table stores all the options set under Administration > Settings panel.

The settings stored here include the URL, the title, installed plugins, and more. The majority of plugins store their settings here, too.

Also stored in this table are all the WordPress dashboard settings.  Unlike other tables, the wp_options table does not relate to any other table.


This table holds the list of all registered users on your WordPress site together with their basic information. This includes login, password (encrypted), email address, registration time, display name, status, and activation key (when necessary).


Metadata is a set of additional data about other data. As noted, the wp_user table stores the basic information about the site users.

The wp_usermeta table holds additional data that is not stored in the wp_uset table. This includes, for instance, the users’ last names.


The wp_terms table stores the categories for posts and links and the tags for posts.

Terms are items of the system used to classify objects. For instance, it’s possible to classify posts and custom posts in different ways.

When creating a post there is the option to add a category and tags to it. Those are examples of taxonomy – a system of classifying and grouping things.

The wp_term table contains a column called “slug.” A slug is a tag of a specific post.

In WordPress, you can connect posts, pages, and links using tags.


As the name indicates, this table describes the taxonomy for the entries in the wp_term table. The taxonomy could be a category, link, or tag.

The structure of this table allows you to use the same term for different taxonomies. For instance, the term “database” could be a category for posts and also a custom taxonomy for a custom post type.

So the term “database” would occur once in the wp_terms table, but twice (two rows) in the wp_term_taxonomy table.


This is where WordPress stores the critical data as regards using taxonomies.

The wp_post table stores the post data. The wp_term_relationship table records the set category and tags.

It defines a relationship between a post (object) in the wp_post table and a term of a specific taxonomy in the wp_term_taxonomy table.

For example, this post is associated with a category and several tags. The wp_term_relationship table is responsible for maintaining that association.


Links are like letters of recommendation.

A blogroll is a list of all external links, most often displayed in a website’s sidebar. Blogrolls were very popular up until a few years ago.

The idea was for website owners to make smart decisions when linking to another website. However, some site owners abused the blogroll feature and so WordPress removed it.

The wp_links table is the storage area for all data related to blogrolls and links. It’s now quite unusual to find the wp_links table since blogrolls are not used anymore.


Wp_comments stores all the comments left on your WordPress posts or pages. It also holds information about the author of the comment.

This information may include name, email address, and comment type (simple, pingback, or trackback).

If using a third-party service (e.g. Disqus), the storage of comments will occur on that system’s server.


Wp_commentmeta contains additional information about each comment. Comment metadata includes:

  • meta_id – a unique number assigned to each row
  • comment_id – the ID of the post the data relates to (a reference to the wp_comments table)
  • meta_value – the piece of data
  • meta_key – an identifying key to the piece of data


This is a new table introduced in WordPress 4.4. It stores additional information about terms (data not stored in the wp_terms table).

It’s possible to access the term meta using the following functions:

add_term_meta, get_term_meta, update_term_meta, and delete_term_meta.

Developers use term meta to hold custom data about terms in a standard way. For instance, to attach an image against a post category to be shown on the category archive page.

Hey, did you know data can be beautiful too?

wpDataTables can make it that way. There’s a good reason why it’s the #1 WordPress plugin for creating responsive tables and charts.

An actual example of wpDataTables in the wild

And it’s really easy to do something like this:

  1. You provide the table data
  2. Configure and customize it
  3. Publish it in a post or page

And it’s not just pretty, but also practical. You can make large tables with up to millions of rows, or you can use advanced filters and search, or you can go wild and make it editable.

“Yeah, but I just like Excel too much and there’s nothing like that on websites”. Yeah, there is. You can use conditional formatting like in Excel or Google Sheets.

Did I tell you you can create charts too with your data? And that’s only a small part. There are lots of other features for you.

FAQ about WordPress database schema

What is the WordPress database schema?

Diving into the schema, it’s a complex map detailing how WordPress arranges its data—think tables and fields. It’s the backbone of your site, housing everything from posts to user details. Cracking this code can radically enhance your site’s effectiveness and speed, truly a game-changer.

How can I access and edit the WordPress database?

Accessing the database often happens through phpMyAdmin or similar database management tools. Once in, you’re in the cockpit, ready to navigate tables and entries. Handle with care, though; one wrong move could mean turbulence for your site’s functionality. Always back up before tinkering!

What can cause errors in the WordPress database?

Errors can come from compatibility hiccups with new plugins or themes, or from a server that decides to take an unscheduled nap. Sometimes, it’s just a case of outdated or corrupted files. Regular updates and backups can save you a migraine level disaster.

Can I change my WordPress database prefix?

Absolutely, you can tailor it for better security. It’s like giving your database a secret handshake. Changing the prefix helps in dodging those pesky SQL injection attacks. But heads up—it requires a careful dance of editing wp-config and executing MySQL queries.

What is the WPDB class in WordPress?

The WPDB class is your toolkit for database creativity, bridging PHP and MySQL’s world. You’ll be crafting queries like an artisan, fetching and manipulating database content without breaking a sweat. Mastery of WPDB means you’re speaking the database’s native language fluently.

How do I backup my WordPress database?

It’s your safety net. Plugins like UpdraftPlus or the WP-CLI command do the heavy lifting, ensuring that, should the sky fall, you have an escape hatch. Or for the hands-on crew, export the database via phpMyAdmin. Think of it as an “undo” button on a very powerful remote.

How does the WordPress database structure affect website performance?

Imagine it as the engine beneath your site’s hood. A well-organized, optimized database means smooth sailing at warp speed. It’s all about the swift retrieval of data, minimal overhead, and streamlined queries. Keep it clean, and your site won’t just walk; it’ll run.

Is it possible to optimize the WordPress database?

For sure, consider it your site’s workout routine—shedding excess data, running a tight ship. Routine cleanups, deleting unnecessary plugins, and optimizing tables. It’s like decluttering – less mess equals better performance.

How do WordPress themes affect the database?

Themes—the face of your WordPress site, but they’re not just skin-deep. They can pack a punch in your database with additional tables or fancy metadata. Choose wisely; an overly complicated theme can bloat your system, slowing down the fiesta.

What is the relationship between WordPress plugins and the database?

Plugins are like your site’s little helpers—each adding its own sprinkle of tables or data to the mix. They enhance functionality but choose your companions wisely—too many, and your database starts resembling a chaotic flea market.


Whew, we’ve surfed the digital waves of the WordPress database schema and emerged wisdom-rich. It’s been a journey through the sinews of our WordPress sites, navigating tables like a pro, understanding the database as the heartbeat—pulsing with every click and post.

  • Tables conquered.
  • Queries decoded.
  • Optimization strategies locked in.

What a ride, right? The database is no longer an enigma wrapped in a riddle, but a friend we high-five on our way to a slicker, swifter WordPress experience. With this guide, the database’s labyrinthine corridors have been illuminated, and those once cryptic MySQL commands? Now just another tool in the belt.

Remember, a pristine, well-oiled database means a user experience that’s as smooth as that first sip of morning coffee. So, let’s embrace that WPDB class, back up like a boss, and keep our databases as snappy as a fresh-out-the-box theme. Now, go forth and craft that WordPress masterpiece. Let the data dance!

If you enjoyed reading this article on WordPress database schema, you should check out this one about how to do a WordPress database reset.

We also wrote about a few related subjects like how to find and replace URLs in WordPress databases, WordPress database plugins, WordPress Excel spreadsheet plugins, how to do a WordPress database cleanup, and how to scan the WordPress database for malware.

Milos Timotic
Milos Timotic

Full Stack Web Developer

Articles: 41