Understanding How WordPress uses MySQL

WordPress is arguably the most popular content management software (CMS) available. The fact that WordPress is free, easy-to-use and has a tremendous amount of support available makes it an ideal CMS for creating and managing a website or blog.

While WordPress is designed to be easy-to-use, it also has enough complexity that allows you to create about anything for your website. For the average user, however, you won’t need to manage this complexity as there are plugins and templates to do most of the work for you. For others, you may want to look at what WordPress has to offer.

A WordPress site can be typically divided into two segments:

  1. The general look and feel of a WordPress website generated by logic and templates.
  2. A MySQL database in which all content powering the website is stored.


Understanding how WordPress uses MySQL

What is MySQL?

MySQL is a very powerful and robust, but surprisingly lightweight, database which powers all WordPress sites. This is one of the advantages of using a robust content management system like WordPress, all the user’s database requirements are managed by the application, so that the end user is almost unaware of its existence.

This means that users and even designers using WordPress do not need to have a working knowledge of the database system in order to get their work done. This post however, is written for those curious minds without expert knowledge, but who still want to delve into MySQL.

In a nutshell, MySQL is one of the relational database management systems (RDBMS). An RDBMS can be described as a container specifically designed for the running and handling of SQL (Structured Query Language). SQL is responsible for powering any database; it gives it form and structure and records any modifications, insertions and deletions carried out on the database.

How MySQL Works

SQL in a database organizes information in tables. Imagine that the table resembles an Excel spreadsheet. A predetermined structure regulates how information is stored in each row and column. Unlike the excel spreadsheet however, the identity and structure of columns in a MySQL database are predefined, referred to as fields or keys.

This defined structure for tables has been set in advance, and can only be changed by a WordPress plugin or a core WordPress update. Even before a single record has been placed in the table, all the fields of that table have been set.

The data types are also preset and their information is stored in the tables. For instance, INT identifies integers, VARCHAR and TEXT identify text fields, DATETIME identifies the date and time etc. This means that if WordPress (or someone with unauthorized access) tries to add data into the database without matching the preset data types, the data will be rejected.

The Relational Capability of MySQL

Tables and keys (or fields or columns) in any table can be related to other keys in other tables, which gives SQL databases unique functionality. This means that users can build databases such that they are tightly related to each other for higher efficiency and greater organization.

WordPress uses this relational ability to relate a lot of its data. Take one of the core tables in WordPress wp_postswhich stores relevant data about posts in WordPress, and another wp_commentswhich holds comments made on specific posts. The two tables are separate, but are contained in the sale database. WordPress will build a relationship between the fields in the two tables so that the database knows which blogpost has which comments.

When WordPress is initially set up, the table and database structure is already existent. Each change made by the user is then used by WordPress to manipulate the rows of each table, making the site fully operational.

Tom Foster is an expert in database administration.For more information on WordPress, SQL, Oracle and other database management and administration procedures, contact the expert by visiting his website.

Follow Me