How a database works

Think of a database as a set of linked tables. One holds products, another customers, a third orders. Each order remembers which customer placed it and which products it contains. When someone opens a page, the back end pulls the data it needs from the database and builds the page from it.

Most WordPress sites use a MySQL or MariaDB database. The site's files, such as images and code, are stored separately. So a website consists of two parts, and both need backing up.

Why it matters

The database holds the most valuable things on your site – orders, customer accounts, texts, settings. Lost theme files can be uploaded again; lost orders from the past week cannot. That is why backing up the database matters more than anything else.

The database affects speed as well. Over the years it fills up with old post revisions, temporary data from plugins you uninstalled long ago, and spam comments. The site then searches through far more data than it needs on every visit.

A real-world example

After six years, a sports equipment shop had a database several times larger than necessary. Most of it was leftover records from old plugins and thousands of saved product revisions. After a clean-up and a limit on revisions, both the admin area and the checkout got faster, and backups took less time.

Tips

  • Back up the database daily, and more often for a shop with a lot of orders.
  • Store backups off the server so you do not lose them along with the site.
  • Always make a backup before cleaning the database – without one, deleted data cannot be restored.
  • Use strong database credentials and do not share them by email.

I clean up and optimise databases as part of website speed optimisation. For custom web applications, I design the database to handle future growth too.