next up previous contents index
Next: 4.3 Search Templates Up: 4 Searching Previous: 4.1 Introduction to Searching

4.2 More Advanced searches

 In addition to performing the simple searches discussed in the previous sections, nxqddb provides some special types of searching. These more advanced search techniques are discussed in this section.

4.2.1 The Generic Search for field

Each nxqddb window contains a Search for field(see figure 4.1). This field is expressly used for searching and is therefore only active while in Search mode.

  figure616
Figure 4.1: The Search for Field


This Search for field provides a special searching capability. Values entered in this field are compared against all the fields. If a match is found in any of the fields, the record is returned.

For example, suppose you type Rex in the Search for field. The people returned would be those records that contained Rex in any field. Suppose you had the following people(see table 4.1), each one of these people would be returned from the search since they each have the value Rex in at least one field.

  table626
Table 4.1: Search data example

4.2.2 Searching on Multiple fields

 nxqddb provides the capability to search on more than one field. There were some sample searches discussed earlier that illustrated this technique.

Steps to searching multiple fields

To search on more than one field, you follow these steps:

  1. As in any other search, be sure your window is in Search Mode. If you're not in Search Mode, click the Edit/Search Mode menubutton to enter Search Mode.
  2. For each field that you'd like to search, key in the appropriate search value.
  3. Press the Enter key.

Example of searching multiple fields

For example, suppose you would like to find a person named John Doe who lives in Ludlow. You could find this information by following these steps:

  1. Key in John in the first name field.
  2. Tab to the Last Name field and key in Doe.
  3. Tab to the City field and then key in Ludlow.
  4. Once you've entered all the fields, press the Enter key.
The results will be displayed in a search results listbox if there are more than one instance. Again, if there is only one instance, then the instance data will be displayed in the search window and the Mode will change from Search Mode to Change Mode.

Note, the results returned will be those instances that match on all three fields. That is, you'll receive only those instances where the Name is John Doe who lives in the city of Ludlow. In other words, the result is the intersection of instances whose (1) first name equals John, (2) last name equals Doe and (3) city equals Ludlow.

There is no limit to the number of fields that you can search on. You can search on any field displayed in the window, provided that you can tab into the field while in Search mode.

4.2.3 Searches with more than one value(Comma Delimiter)

  You can specify more than one search field value simply by delimiting the values by commas. For example, suppose you wanted to find all the people whose name is either Timothy OR Carol. You would do these steps:

  1. On the window, be sure you're in Search mode. If you're not in Search mode, click the Edit/Search Mode menubutton to go to Search Mode.
  2. Press the Edit/Clear menubutton to be sure that no other fields are populated.
  3. Tab to the first name field.
  4. Key in Timothy , Carol
  5. Press the Enter key

Of course, you can have multiple search fields whereby each search field can specify one or more search values. This type of search basically combines the above two search techniques. Lets clarify this with an example.

Suppose you'd like to find all people that have a last name of either Simpson or Flanders and who live in the city Springfield or Chicago. To find these instances, you would follow these steps:

  1. Tab to the last name field.
  2. Key in simpson , flanders. (Remember, case is insignificant in search mode)
  3. Tab to the city field.
  4. Key in springfield , chicago
  5. Press the Enter key.

There is no limit to the number of fields or the number of search field values.

4.2.4 Specifying search values in a Date Field

You can do searches on date fields. The format for entering dates is mm/dd/yy where (1) mm denotes the month, (2) dd denotes the year, and (3) yy denotes the year.

Valid date entries are shown below:


Date entries must not contain any spaces.

You may also enter dates related to some date. nxqddb provides some keywords (or short cuts) for specify dates. These shortcuts are listed in table 4.2.

  table691
Table 4.2: Generic Search For Field

You may also use the day-of-week keywords Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday. Month names are also fine. For example, the following are all valid input to a date attribute:
tabular718

The input ``next tuesday'' does not mean this coming (or current) Tuesday, but the one after. The keyword ``tuesday'' means the coming (or current) Tuesday.

4.2.5 Specifying Ranges for Numeric and Date Field

 nxqddb provides the ability to perform range searches on Numeric and Date fields. Since our guestbook doesn't have any numeric fields, we'll create a new schema for handling, say invoices. When we refer to the ``Invoices'' window, we'll be referring to the nxqddb window displayed using the schema shown in figure 4.2.



Use Reduced Attribute Identifiers
Use Cached Hashing
CacheSize = 500
HashSize = 20000

Number verbosename "Invoice Number" type integer
Client (
        ID verbosename "Client #" type integer
        Name 
)
Date type date
Time exclude
DayOfWeek verbosename "Day of Week"
Pet (
        PetID verbosename "Animal #" type integer
        PetName verbosename "Animal Name"
        Doctor
        Personnel
        EntryCode verbosename "Entry Code"
        Items (
                Qty type integer
                Code
                SvcType
                Desc verbosename "Description"
                Taxable exclude
                Price type real format "%.2f" exclude
                Total verbosename "Line Total" type real format "%.2f" exclude
                DiscountedTotal verbosename "Discounted Total" type
                        real format "%.2f" exclude
        )*
        Subtotal type real format "%.2f" exclude
)*
Subtotal type real format "%.2f" exclude
Discounts type real verbosename "Discounts" format "%.2f" exclude
Tax type real verbosename "Sales Tax" format "%.2f"
Total verbosename "Invoice Total" type real format "%.2f" exclude
PaymentType verbosename "Type of Payment"
PaymentAmount verbosename "Payment Amount" type real format "%.2f" exclude
PreviousBalance verbosename "Previous Balance" type real format "%.2f" exclude
AmountDue verbosename "Total amount due" type real format "%.2f"

  
Figure 4.2: Invoice Schema





Actually, the schema shown in figure 4.2 is taken directly from a commercial application -- Faunix. If you'd like to view the schemas(and complete source code for that matter), visit http://www.hsdi.com on the internet.

A range search is performed by keying the lower limit(or value) followed by a dash followed by the upper limit.

Range search on a numeric field

For example, suppose you wanted to find all the invoices in the range 100 through 200. The following steps show you how to find this range of invoices including the invoice 100 and invoice 200. nxqddb range searches return the lower and upper limits.

  1. On the Invoices window in Search Mode.
  2. Tab to the Invoice Number field.
  3. Key in 100-200 and press the Enter key.

Range search on a date field

You can also perform range searches on date fields. Similarly to range searching on numeric fields, you specify a range search by keying in the lower limit value (or starting date) followed by a dash, followed by the upper limit(or ending date).

The following examples illustrate range searches on date fields:

Find invoices created in July, 1996
From the Invoices window, tab to the Date field, Key in 07/01/96-07/31/96 and press the Enter key.

Find invoices created for 1996
From the Invoices window, tab to the Date field, Key in 01/01/96-12/31/96, and press the Enter key.

@firstofmonth(today) and @lastofmonth(today)

    There are many times that you may want to find information for an entire month. To simplify this task, nxqddb provides two special functions: @firstofmonth(today) and @lastofmonth(today).

These two functions find the first/last day of the month. For example, suppose today's date was say 10/11/96. Then, nxqddb would convert the following:

These two functions are especially useful for storing search templates that are run every month. Using these special functions allows you to not have to re-key the date fields each time you perform your search.

4.2.6 Exclusion using exclamation point(!) delimiter

  nxqddb allows you to search for instances where a field does NOT equal some specified value.


Suppose you wanted to find all the invoices for March, 1996 but excluding those from March 5, 1996. You could accomplish this by keying 03/01/96-03/31/96 ! 03/05/96 in the Invoice Date field on the Invoices window.

Suppose you would like to find all people except for those named Smith. To accomplish this, follow these steps:

  1. From the AddressBook2 window, in Search Mode, tab to Last Name field.
  2. Key in .* ! Smith and press the Enter key.


Note, the special characters .* is a regular expression that tells nxqddb to search for all instances. Suffixing the .* with the ! Smith then tells nxqddb to exclude all the instances that contain the word Smith. The end result is that all clients not named Smith will be found.

4.2.7 Regular expression searches

 nxqddb provides regular expression searches. A regular expression search is a way to specify wild cards in your search. To accomplish this searching technique, you use the dot-star character combination(.*).

If you enter .* in a search field, nxqddb will return all the instances in the database. For example, if you're in the AddressBook2 window and enter .* in any field, then all the people will be displayed in the search results listbox.


Searching using the .* may result in long searches if you use no other search constraints. Typically, you would not want to just search on .* only. Rather, you would combine the .* with other search values.

Here are some sample searches and their results using the .* wild-card.

Find all people
Tab to any field, key in .*, and then press the Enter key.
Find all people whose first name starts with the letter A
Tab to first name field, key in A.*, and then press the Enter key.
Find all people whose first name starts with the letters Al
Tab to first name field, key in Al.*, and then press the Enter key. If your addressbook had people with names Al, Albert, Alfred, Allen, and Alberta -- all of these names would be returned.
Find all people whose first name starts with the letter A and ends in the letter n
Tab to first name field, key in A.*N, and then press the Enter key. If your addressbook had people with names Al, Albert, Alfred, Allen, and Alberta -- only Allen would be returned since its the only name that starts with an A and ends with an N.
Find all people living in zip codes starting with 405
Tab to zip code field, key in 405.*, and then press the Enter key. All zip codes starting with 405 would be returned. If your addressbook had people living in 40502, 40503, 40521 -- all of these people would be displayed in the Search results listbox for you to browse, update or print.

4.2.8 Grouping search values using curly braces ({})

 If you want to build more complex searches, you can group search values using curly braces({}).


To search for "Billy Ray", Tommy, and Jack you would
  1. tab to the first name field.
  2. key in {Billy Ray} , Tommy , Jack
  3. press the Enter key.

The braces surrounding { Billy Ray } are required since there is a blank between Billy and Ray.


next up previous contents index
Next: 4.3 Search Templates Up: 4 Searching Previous: 4.1 Introduction to Searching

Herrin Software Development, Inc.