Web designers and developers who have worked their way through , and tend to regard databases as rather esoteric and ethereal things. But databases exist as a very real core component of the modern web, and are the final component of the (W|M|L)AMP stack that we will learn to create a complete web site.

Databases are used to record website data that is either:

  1. open to addition, removal or modification, such as customer information (mailing and eMail addresses of users, for example) or a limited amount of text that you might want to have the client/site owner change, without having to worry about ruining anything in your HTML or CSS, as in a CMS.
  2. Available for the user to sort or search, such as product information or entries in a blog.

At their root, databases are nothing more than related tables of data. They are, at a simple conceptual level, very similar to the spreadsheets that you may be familiar with in Excel or similar applications: columns defining what kind of data is placed in them (in MySQL, referred to as fields), and rows containing different records, each row being defined by a sequence of data across multiple fields, read in a single horizontal line.

It is a frequent mistake of learners to try to make a single database table that attempts to record every single bit of data for your site. Instead, it is usually much more efficient to make several database tables, each recording different aspects of a site (comments, user details, etc., each in a separate table) that share a common unique key, such as a user ID. Using a language such as you can then query from multiple tables to get the information you require. Most modern databases are relational: that is, they organize data based on principles (known as a schema) by which data in different tables can relate to each other.

Despite this, it is fairly common to use the terms “database” and “table” interchangeably, much as people confuse “web” and “Internet”.

Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.