Basic database applications

See more about:

A database is an collection of structured data. “Structured” means that the same data is stored for a bunch of different things. This timetable has some structured data:

Timetable

Figure 1. Timetable

There are a bunch of rail stops. Each one has a name (e.g., Hicksville) and a price (56 cents). The same type of information is stored for each stop: name and price.

Here’s another example of structured data. It’s part of actress Alyson Hannigan’s filmography.

Alyson Hannigan's filmography

Figure 2. Alyson Hannigan’s filmography

OK, so I have a thing for Willow.

There are a bunch of films. For each one, there’s the same data: year, film name, and role. The format of the data is predictable.

Structured data is often shown in tables, as you can see.

Here’s one more example.

Most popular dog breeds in the US

Figure 3. Most popular dog breeds in the US

Again, there’s a table, with rows and columns. Each row is about a dog breed. Each column has data about breeds. Every row has the same format.

So structured data has predictable information about things of the same type, like rail stops, films, or dog breeds. What’s unstructured data look like?

Here’s some unstructured data.

Ozymandias

Figure 4. Ozymandias

It’s the poem Ozymandias, by Shelley. There’s no predictable format.

PHP programs have an easier time processing structured than unstructured data. For example, a PHP program could take the dog breed data and compute the total number of registrations.

But there isn’t much a PHP program can do with a poem, except show it. It couldn’t tell you what the poem meant.

So a database is a collection of structured data. Some Web sites draw information from databases to create Web pages. For example, Amazon.com has a database, with data on the products they have. When your browser asks for a page, a program runs on their server. It gets product information from their database, and makes an HTML page out of it.

Amazon page

Figure 5. Amazon page

When you order something, your order goes into the database. Order data is structured. Each order has the same type of data: date, customer, products, etc. So one database can have structured data about different types of things: orders, customers, products, ...

A program tells the shipping people that there is a new order. They look in the database, and see your order. They put your stuff in a box, mail it to you, and update the database to show that the order was shipped.

The database ties different parts of the business together. Sales, shipping, receiving, billing, ... They all use data from the database.

DB ties business together

Figure 6. DB ties business together

This chapter shows you how database Web applications work. As usual, you’ll do a lot of hands-on stuff.

The chapter talks about databases that have just one table in them. I’ve found that people have trouble understanding databases with more than one table, because of table relationships. So I’ll delay talking about relationships until you know how single-table databases work.

You’ll need a Web hosting account with MySQL. If you followed my earlier recommendations, you have one.

Let’s start by looking at some sample database applications, so we know what we’re trying to acomplish.


How to...

Lessons

User login

Log in problems? Try here


Dogs