home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeMySQL and mSQLSearch this book

1.3. Applications and Databases

According to our definition of a database, a database is an organized collection of data that serves some purpose. Just having a DBMS is not sufficient to give your database purpose. How you use your data defines its purpose. Imagine a library where nobody ever reads the books. There would not be much point in storing and organizing all of those books if they were never used. Now, imagine a library where you could not change or add to the collection. The utility of the library as a database would decrease over time since obsolete books could never be replaced and new books could never be added. In short, a library exists so that people may read the books and find the information they seek.

Databases exist so that people can interact with them. In the case of electronic databases, the interaction occurs not directly with the database, but instead indirectly through software applications. Before the emergence of the World Wide Web, databases typically were used by large corporations to support various business functions: accounting and financials, shipping and inventory control, manufacturing planning, human resources, and so on. The web and more complex home computing tasks have helped move the need for database applications outside the realm of the large corporation.

1.3.1. Databases and the Web

The area in which databases have experienced the most explosive growth -- an area where MySQL and mSQL excel -- is in web application development. As the demand for more complex and robust web applications grows, so does the need for databases. A database backend can support many critical functions on the web. Virtually any web content can be driven by a database.

Consider the example of a catalog retailer who would like to publish on the web and accept orders online. If the catalog were published as HTML files, someone would have to hand edit the catalog each time a new item was added or a price changed. If the catalog information were instead stored in a relational database, it would be possible to publish real time catalog updates simply by changing the product or price data in the database. It would also become possible to integrate the online catalog with existing electronic order processing systems. Using a database to drive such a web site thus has obvious advantages for both the retailer and the customer.

Here's how a web page typically interacts with a database. The database is on your web server or another machine that your server can talk to (a good DBMS makes this kind of distributed responsibility easy). You put a form on one web page that the user fills in with a query or data to submit. When the form's query is sent to your server, it runs a program that you write that extracts the data submitted by the user. These programs most often come in the form of CGI scripts and Java servlets, but can also occur by embedding programming right inside the HTML page. We will look at all of these methods in this book.

Now your program knows what the user is asking for or wishes to add to the database. The program issues an SQL query or update, and the database magically takes care of the rest. Any results obtained from the database can be formatted by your program into a new HTML page to send back to the user.



Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.