This tutorial describes web database applications built around a three-tier architecture model, shown in Figure 1-1. At the base of an application is the database tier, consisting of the database management system
that manages the database containing the data users create, delete,
modify, and query. Built on top of the database tier is the complex middle tier, which contains most of the application logic and communicates data between the other tiers. On top is the client tier, usually web browser software that interacts with the application.
Figure 1-1. The three-tier architecture model of a web database application
The formality of describing most web database applications as
three-tier architectures hides the reality that the applications must
bring together different protocols and software. The majority of the
material in this tutorial discusses the middle tier and the application
logic that brings together the fundamentally different client and
When we use the term "the Web," we mean three major, distinct
standards and the tools based on these standards: the Hypertext Markup
Language (HTML), the Hypertext Transfer Protocol (HTTP), and the TCP/IP
networking protocol suite. HTML works well for structuring and
presenting information using a web browser application. TCP/IP is an
effective networking protocol that transfers data between applications
over the Internet and has little impact on web database application
developers. The problem in building web database applications is
interfacing traditional database applications to the Web using HTTP.
This is where the complex application logic is needed.
The Client Tier
The client tier in the three-tier architecture model is usually a
web browser. Web browser software processes and displays HTML resources,
issues HTTP requests for resources, and processes HTTP responses. As
discussed earlier, there are significant advantages to using a web
browser as the thin-client layer, including easy deployment and support
on a wide range of platforms.
There are many browser products available, and each browser product
has different features. The two most popular windowing-based browsers
are Netscape and Internet Explorer. While we won't describe all the
features of web browsers, they have a common basic set:
All web browsers are HTTP clients that send requests and
display responses from web servers (usually in a graphical environment).
All browsers interpret pages marked up with HTML when rendering
a page; that is, they present the headings, images, hypertext links,
and so on to the user.
Some browsers display images, play movies and sounds, and render other types of objects.
<form> or change how a page is presented based on user actions.
Selected web browsers can run components developed in the Java
or ActiveX programming languages. These components often provide
additional animation, tools that can't be implemented in HTML, or other,
more complex features.
Several browsers can apply Cascading Style Sheets (CSS) to HTML pages to control the presentation of HTML elements.
There are subtle-and sometimes not so subtle-differences between
the capabilities different browsers have in rendering an HTML page.
Lynx, for example, is a text-only browser and doesn't display images or
sound-the spoken word-providing web access for the vision-impaired.
Many subtle but annoying differences are in the support for CSS and the
features of the latest HTML standard, HTML 4.
Web browsers are the most obvious example of a user agent, a software client that requests resources from a web server. Other user agents include web spiders-automated software that crawls the Web and retrieves web pages-and proxy caches, software systems that retrieve and locally store web pages on behalf of many other user agents.
The Middle Tier
In most three-tier web database systems, the majority of the
application logic is in the middle tier. The client tier presents data
to and collects data from the user; the database tier stores and
retrieves the data. The middle tier serves most of the remaining roles
that bring together the other tiers: it drives the structure and content
of the data displayed to the user, and it processes input from the user
as it is formed into queries on the database to read or write data. It
also adds state management to the HTTP protocol. The middle-tier
application logic integrates the Web with the database management
In the application framework used in this tutorial, the components
of the middle tier are a web server, a web scripting language, and the
scripting language engine. A web server processes HTTP requests and
formulates responses. In the case of web database applications, these
requests are often for programs that interact with an underlying
database management system. The web server we use throughout this
tutorial is the Apache Software Foundation's Apache HTTP server, the open source web server used by more than 60% of Internet connected computers.
From The Netcraft Web Server Survey, http://www.netcraft.com/survey/ (April 2001).
We use the PHP scripting language as our middle-tier
scripting language. PHP is an open source project of the Apache Software
Foundation and, not surprisingly, it is the most popular Apache HTTP
server add-on module, with around 40% of the Apache HTTP servers having
PHP capabilities. PHP is particularly suited to web
database applications because of its integration tools for the Web and
database environments. In particular, the flexibility of embedding
scripts in HTML pages permits easy integration with the client tier. The
database-tier integration support is also excellent, with more than 15
libraries available to interact with almost all popular database
Web servers are often referred to as HTTP servers. The term
"HTTP server" is a good summary of their function: their basic task is
to listen for HTTP requests on a network, receive HTTP requests made by
user agents (usually web browsers), serve the requests, and return HTTP
responses that contain the requested resources.
There are essentially two types of request made to a web server: the
first asks for a file-often a static HTML web page or an image-to be
returned, and the second asks for a program to be run and its output to
be returned to the user agent. Simple requests for files are further
discussed in Appendix B.
Requests for web scripts that access a database are examples of HTTP
requests that require a server to run a program. With the software used
in this tutorial, the HTTP requests are for PHP script resources, which
require that the PHP Zend engine be run, a script retrieved and processed, and the script output captured.
hope this helps you...