The qualification

The SQL qualification restricts the set of rows returned to the user. The qualification filters out records that are not interesting. Only the records that pass the qualification are evaluated in the target list. Thus, a qualification is a more powerful tool than the target list.

A single expression in a qualification is called a predicate. A qualification can contain multiple predicates joined by the Boolean operators AND and OR.

If a DataBlade® module routine is used in a qualification, it filters the records returned to the client. Your database server can filter by the contents of new data types. (This capability is not available in conventional relational databases.)

Consider whether the routines you define are more likely to be used in the target list or the qualification. Routines more commonly used in the qualification make better use of the extensibility of your database server because they support searches that cannot be done efficiently on conventional relational servers.

The following example shows a DataBlade module routine used in a qualification:
SELECT name, boundary FROM cities WHERE 
   Overlaps(boundary, '(1,1), (5,5), (7,7), (8,9)');

In this example, the Overlaps() routine is provided by the SimpleMap DataBlade module and takes two polygon arguments: the first argument specifies the polygon you are checking; the second specifies the polygon with which the first is compared. Overlaps() returns TRUE if the two polygons overlap and FALSE otherwise. This query searches the cities table for those cities that overlap the region of interest.

The separation between routines used in the target list and those routines used in the qualification is not absolute. For example, the following query finds the names and populations of large cities:
SELECT name, population FROM cities 
   WHERE Area(boundary) > 500;

In this example, the Area() routine appears in the qualification. In the section ids_dbdk_029.html#ids_dbdk_029, the Area() routine appeared in the target list.

Some routines are better suited to the qualification than the target list. A good example of this distinction is the Overlaps() routine. This routine is more powerful in the qualification. While it is possible to formulate a query like the following example, it is not common:
SELECT Overlaps(boundary, '(1,1), (5,5), (7,7), (8,9)') 
   FROM cities;
This query returns a list of yes-or-no answers for each city in the table that overlaps the supplied constant polygon. It is more common to use the Overlaps() routine to filter rows than to compute values returned to the user. However, important and useful exceptions to this rule exist, as follows:
SELECT a.name, Overlaps(a.boundary, b.boundary) 
   FROM cities a, cities b
   WHERE b.name = 'Los Angeles' AND
   a.name = b.name;

This query returns a list of all cities in the table and whether they overlap Los Angeles.

To help decide which routines to include in the DataBlade module, consider the following questions:
  • What questions do users want to ask about the contents of the new data types in the DataBlade module?
  • What routines allow them to ask those content-based questions? These routines are used in the qualification.