Databases are very important to web development because they are the main way of storing large quantities of easily accessible and updateable data. For example, online order systems need somewhere to permanently store customer and order details, and even a simple message board needs somewhere to store and retrieve messages.
We may ask, "Why not store data in plain text files rather than a database?" This would be possible, but not very efficient. Databases don't just store data; they also organize it, sort it, and make it very easy for us to find and retrieve just the data we want. For example, an online bookseller such as Amazon may have a million or more books, and want to allow customers to search for specific books by the author name, year of publication, book title, or publisher. If we had one, or even many, text files holding all the book information, it would prove a massive undertaking to try to find all the books published by Wrox Press between the years 1999 and 2002. A database makes a task such as this very easy because ways of sorting and retrieving the data are built into its structure. Of course, we still need to design the database correctly, but if we get that right we find data retrieval is fast and easy. One further advantage of database management systems is the ability to synchronize updates—for example, where you have a website with multiple users at the same time trying to add information to a file or a database.
In this chapter, we'll look at the theory behind relational databases, and how to create our own database, using Microsoft Access as an example. However, building the database is only half the problem; we want to access it from our web pages too.