JavaScript Editor JavaScript Validator     JavaScript Editor 



Team LiB
Previous Section Next Section

Chapter 17: Databases

Overview

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.

The solution to this problem is made very easy because Microsoft supplies components called ActiveX Data Objects that make searching for and storing information using server-side JavaScript and ASP very easy. The components are either present on your Windows operating system or installed when you install Microsoft's Internet Information Server (IIS).

We'll look at how to use these components to access a database using server-side script later in the chapter. Since we are using server-side script, the database must be in a place that the server, IIS in this case, has access to. We won't be looking at database access from client-side JavaScript, which, though possible, is nowhere near as easy, and is too advanced for this book. Needing to access a database client-side is fairly unusual anyway; most of the time server-side access is required.


Team LiB
Previous Section Next Section


JavaScript Editor JavaScript Validator     JavaScript Editor


©