Home arrow MySQL arrow Page 4 - Database Applications and the Web

Thickening the Client in the Three-Tier Model - MySQL

With most of the services on the web being powered by web database applications, it becomes important for any web developer to know how bring together the web and databases to build applications. This article gets you started. It is excerpted from chapter one of the book Web Database Applications with PHP and MySQL, written by Hugh E. Williams & David Lane (O'Reilly, 2004; ISBN: 0596005431).

TABLE OF CONTENTS:
  1. Database Applications and the Web
  2. The Web
  3. HTTP: the Hypertext Transfer Protocol
  4. Thickening the Client in the Three-Tier Model
  5. Web Scripting with PHP
  6. Introducing PHP5
  7. The Database Tier
  8. Why use a database server?
  9. The MySQL server
By: O'Reilly Media
Rating: starstarstarstarstar / 45
September 15, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Given that a web database application built with a three-tier architecture doesnít fit naturally with HTTP, why use that model at all? The answer mostly lies in the popularity and standardization of web browsers: any user who has a web browser can use the web database application, and usually without any restrictions. This means an application can be delivered to any number of diverse, dispersed users who use any platform, operating system, or browser software. This advantage is so significant that our focus in this book is entirely on three-tier solutions that use a web browser as the client tier.

Web browsers are thin clients. This means almost no application logic is included in the client tier. The browser simply sends HTTP requests for resources and then displays the responses, most of which are HTML pages. This thin client model means you donít have to build, install, or configure the client tier, but that you do need to build almost all of your application to run in the middle tier.

You can thicken the client tier to put more work on the browser. Using popular technologies such as Java, JavaScript, and Macromedia Flash, you can develop application components that process data independently of the web server or preprocess data before sending it to the server.

JavaScript is particularly good for many tasks because itís easy to use, open source, and built into all popular browsers (although users can turn it off). Itís often used to validate data thatís typed into forms before itís sent to the server, highlight parts of a page when the mouse passes over, display menus, and perform other simple tasks. However, itís limited in the information it can store and it canít communicate with a database server. Therefore, although you shouldnít depend on JavaScript to do critical tasks, itís useful for preprocessing and itís another important technology we discuss in Chapter 7.

The Middle Tier

The middle tier has many roles in a web database application. It brings together the other tiers, drives the structure and content of the data displayed to the user, provides security and authentication, and adds state to the application. Itís the tier that integrates the Web with the database server.

Web servers

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 or script to be run and its output to be returned. Weíve shown you a simple example previously in this chapter, and simple requests for files are further discussed in Appendix D. HTTP requests for PHP scripts require a server to run PHPís Zend scripting engine, process the instructions in the script (which may access a database), and return the script output to the browser to output as plain HTML.

Apache is an open source, fast, and scalable web server. It can handle simultaneous requests from browsers and is designed to run under multitasking operating systems such as Linux, Mac OS X, and Microsoft Windows. It has low resource requirements, can effectively handle changes in request loads, and can run fast on even modest hardware. It is widely used and tested. The current release at the time of writing is 2.0.48.

Conceptually, Apache isnít complicated. On a Unix platform, the web server is actually several running programs, where one coordinates the others and doesnít serve requests itself. The other server programs notify their availability to handle requests to the coordinating server. If too few servers are available to handle incoming requests, the coordinating server may start new servers; if too many are free, it may kill spare servers to save resources.

Apacheís configuration file controls how it listens on the network and serves requests. The server administrator controls the behavior of Apache through more than 150 directives that affect resource requirements, response time, flexibility in dealing with request load variability, security, how HTTP requests are handled and logged, how scripting engines are used to run scripts, and most other aspects of its operation.

The configuration of Apache for most web database applications is straightforward. We discuss how to install Apache in Appendixes A through C, how to hide files that you donít want to serve in Chapter 6, and the features of a secure web server in Chapter 11. We discuss the HTTP protocol and how itís implemented in Appendix D. More details on Apache configuration can be found in the resources listed in Appendix G.



 
 
>>> More MySQL Articles          >>> More By O'Reilly Media
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: