Home Passing Data Between Pages Web Applications PHP and MySQL ASP Web Databases References Sample Site

 

How a Web Application Works

When a web server receives a request for a regular web page, the server sends the page to the requesting browser , the web server reacts differently when it receives a request for a dynamic page: it passes the page to a special software extension responsible for finishing the page. This special software is called an application server.The application server reads the code on the page, finishes the page according to the instructions in the code, then removes the code from the page. The result is a static page that the application server passes back to the web server, which then sends the page to the requesting browser. All the browser gets when the page arrives is pure HTML.

Accessing a database

An application server lets you work with server-side resources such as databases. For example, a dynamic page may instruct the application server to extract data from a database and insert it into the page’s HTML. The instruction to extract data from a database is called a database query. A query consists of search criteria expressed in a database language called SQL (Structured Query Language). The SQL query is written into the page’s server-side scripts or tags. An application server cannot communicate directly with a database because the database’s proprietary format renders the data undecipherable in much the same way that a Word document opened in simpletext is undecipherable. The application server can communicate only through the intermediary of a database driver. A database driver is software that acts like an interpreter between the application server and the database. After the driver establishes communication, the query is executed against the database and a recordset is created. A recordset is a subset of data extracted from one or more tables in a database. The recordset is returned to the application server and the data used in the dynamic page.
Here’s a simple database query written in SQL:


SELECT lastname,firstname,matricno
FROM students


This statement creates a three-column recordset and fills it with rows containing the lastname, firstname, and matricno for all the records in the students table. The following diagram shows the process (diagram taken from Getting Started with Dreamweaver MX by Macromedia inc)

 

The choice of which database to use will depend on factors such as how critical the information is, how robust the site has to be, how many users will access the web site, availability of the database and drivers.If you plan to build small low-cost applications, you can use a file-based database, such as one created in Microsoft Access. If you plan to build robust, business-critical applications, you can use a server-based database, such as one created in Microsoft SQL Server, Oracle 9i, or MySQL.