System information
72 Chapter 7: Lesson 4: Building Dynamic Queries
A better solution is to provide an interface for the user to specify the search criteria. The purpose
of the Trip search form is to enable Compass Travel employees to search and view brief details
about existing trips on their website. The completed form should appear as follows:
Designing the search criteria page
When designing the search criteria page, it is a good idea to develop a list of possible queries that
the user might issue when searching for the records. Most Compass Travel customers are
primarily concerned with trip locations, departure dates, and price; the following is a list of the
types of queries that the agents are likely to require at Compass Travel:
• List the trips located in Hawaii.
• Identify the trips with a price greater than $3,000.
• Show the trips departing after 11/11/2005 that are priced less than $2,000.
There are a number of considerations to take into account when you design a search page to
capture the user’s search criteria. The following are two of the most important considerations:
• For which database columns will the user be allowed to specify a search condition?
• Should the user be allowed to identify which database columns to include in the record set?
In this exercise, the Compass Travel trip coordinator searches the trips based on tripLocation,
departureDate, and price. Because these columns are the only ones that users can query, they are
the only ones contained in the WHERE clause of the generated SQL statement. In addition, the
coordinator has no control over which columns are returned in the record set. The query always
returns the same columns to identify a trip:
• tripName
• tripLocation
• departureDate
• returnDate
• price
• tripID