Once you've been sold on using the Web to get information to and from your visitors, someone will no doubt urge you to move a lot of that information into a database. That's good advice. Because databases are designed to handle the storage and retrieval of constantly updated information, they let you incorporate data that changes a lot, such as e-commerce transactions, into your Web site without making the site as slow as molasses.
Your best bet is an SQL (Structured Query Language) database. SQL is the industry-standard tool for extracting information from relational databases. SQL isn't easy, but implementing it pays off in the long run. Using a database as your Web site's back end separates your ever-changing data from the look and feel of your site.
For such a system to work, a number of pieces of technology have to fit together. We'll describe Web/database architecture in general, then take a look at the three approaches that dominate the Web today.
In general, you can't connect a remote user's Web browser directly to a database system. There are exceptions to this (Java applets are one way around it), but in most cases, the browser talks to a program running on the Web server that is an intermediary to the database. This program can be a CGI (Common Gateway Interface) script, a Java servlet, or some code that lives inside an ASP (Active Server Pages) or JSP (JavaServer Pages) document. The user doesn't know whether the page is an ordinary HTML document or the output of some script that generates HTML.
Figure 1 shows the typical interaction between a user and a Web-based database system. First, the user fills out a form on a Web page and clicks the Submit button (step 1). The browser sends the information from the form to the Web server, which passes it on to a CGI script (step 2). Next, the CGI script loads a library that lets it talk to an SQL database server, and it uses that library to send SQL commands to the database server (step 3). The database server stores the information and tells the CGI script that everything went okay (step 4). Next, the CGI script generates an HTML document, which serves as a confirmation, then writes the HTML document to the Web server (step 5), which sends it back to the remote user (step 6), and everything is finished.