|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
You need to decide what bits (entities) of information you want to store and how this information is related to other entities. The usual technique, when designing a database, is to draw a graphical display of the database. This drawing is called an Entity-Relationship (E-R) diagram. If you take a look at Figure 29.2, you can see that each box corresponds to a table. Each line in the box represents a specific field. When required, each box is connected to another where an entity is related to an entity in another table.
The purpose of having relational databases is to limit the amount of repetitive information contained in the database. After someones address is entered in one table, for example, you should never have to provide an address in any other table. Making SQL QueriesStructured Query Language (SQL) is a language that provides a user interface to relational database management systems (RDBMS). Originally developed by IBM in the 1970s, SQL is the de facto standard for storing and retrieving information for relational databases, as well as being an ISO and ANSI standard. The current standard is SQL2, with SQL3, which was released in 1998. The purpose of SQL is to provide a language, easily understandable by humans, that interfaces with relational databases. When adding, removing, and retrieving information from SQL databases, you perform what is called a query. A query is a command that is sent to the database, telling the database engine what to do to manipulate the contents of a database. One example of a query is provided below using the select command. The select command enables you to specifically define what information you want retrieved from the database. You can be as broad or as specific as you want when retrieving information from the database. select * from personal,department,finance where Name=Fred Flintstone This would pull up all information on Fred Flintstonefrom all the tables. You could even be more specific, pulling only certain parts from each table: select Name.finance,Name.department,Tardy.department from department,finance where Tardy > 5 AND Name.finance = Name.department Many commands are used to query a database, providing you with quite a bit of power when working with a relational database. Most SQL servers use basic commands such as select, but minor differences can be noticed. It is best to check the documentation provided with your SQL server for a complete list of commands and the proper syntax for each command. Debugging Database ApplicationsOne of the biggest problems when dealing with databases on the Web is trying to fix any problems that may occur when you are writing your script. First, you can have problems because of a bug in your script. Second, you can have problems because of an improper query. The best way to see whether the problem lies within your script is to create a copy of the script that includes dummy variablesvariables that contain information as if a visitor actually entered something into a form. Using the previous scripts, for example, you can create a set of variables that mimics information that a visitor might have entered: $contents{fname} = John; $contents{lname} = Doe; After you have the dummy variables set, you can execute your script using the command line % /usr/bin/perl phone.pl Perl will report any problems with your script if you have programmed any code improperly. To figure out what may be wrong with your SQL query, you can usually use the console interface provided with your SQL server. If you construct the query with the console interface and everything works fine, then look at your script and see if an error can be produced there.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |