Content-type: text/html; charset=UTF-8 Man page of query

query

Section: Herrin Software Development, Inc. (1)
Updated: 21 Oct 2000
Index Return to Main Contents
 

NAME

query - Query a QDDB database and print the results.  

SYNOPSIS

query Relation [-tcl [-norows]] [-sep 'field separator']
    [-any Value ...] [AttributeName Value ...] [-print AttributeName[:Width] ...]
 

DESCRIPTION

query performs the given query on RelationDirectory and prints the result to stdout in a form suitable for reading by humans or interfacing with TCL.

The field separator is the character(s) that query uses to separate the row output of the attributes specified with the -print option and defaults to ':'. AttributeName is the full name of any attribute in the Schema for RelationName. Value is either a full word or white space separated list of words delimited by single quotes (depending on your shell). The :Width option of -print specifies the number of characters in AttributeName to print.  

HUMAN READABLE OUTPUT

If the -tcl option is not specified, then query prints only attributes in rows matching the query. For example, suppose we have a database called Books that has the following QDDB Schema:

    Use Cached Hashing
    HashSize = 1000

    Author *
    Title
    ISBN
    Description
    Borrower (
        Name
        Phone*
    )*

and contains a small number of popular computer science texts. The query

    $ query Books -sep '***' Author 'donald knuth' -print Title ISBN
might produce
    Fundamental Algorithms***0-201-03809-9***
    Seminumerical Algorithms***0-201-03822-6***
    Sorting and Searching***0-201-03803-X***
and the query
    $ query Books -sep '***' Author 'donald knuth' -print Title:10 ISBN:12
would produce
    Fundamenta***0-201-03809-***
    Seminumeri***0-201-03822-***
    Sorting an***0-201-03803-***
Human-readable output is useful when you want to quickly review the results of a QDDB query from the command line.  

INTERFACING WITH TCL

-tcl instructs query to format its output for use in TCL/TK scripts. -norows is used when the description of the selected row is not needed and is useful to prune the output for non-structured data.

Using the QDDB Schema given in the previous section, we might perform the query:

    $ query Books -tcl -sep '***' Author 'donald knuth' \
        Title 'fundamental' -print Title:10 ISBN:12
and see the output:
    { "Fundamenta***0-201-03809-***"
      { 1 359 0 1 }
      { Author,1 Title,1 ISBN,1 Description,1
        Borrower.Name,1.1 Borrower.Phone,1.1
      }
    }
    { "Fundamenta***0-201-03809-***"
      { 1 359 0 1 }
      { Author,1 Title,1 ISBN,1 Description,1
        Borrower.Name,2.1 Borrower.Phone,2.1
      }
    }

The output of query Books -tcl is a set of lists, each one having the format shown above. Each TCL list contains three elements, the result, the KeyList, and the row description.

The result element is usually used to display a list of items from which the user may choose. The contents of the KeyList element is used as arguments to qread(1) when the user selects from a given list. The row description is useful when the Schema is structured and contains expandable attributes. If the Schema is flat (not structured), then it is often useful to leave out the row description so that the number of bytes the TCL scripts must parse is reduced. Large Schemas produce particularly long row descriptions, especially when the attribute names are long. -norows instructs query not to print the row description.  

SEARCH ALGORITHM

query searches the QDDB Relation on a per-word basis. The result is the intersection of all records containing the words specified in the query. For example,
    $ query Books -any 'arnold palmer' -print Title
will search the QDDB relation named Books for all records that contain one or more fields with the word arnold and the word palmer, irrespective of the fields in which the words are actually contained. The query
    $ query Books Title 'arnold palmer' -print Title Author
will find all records containing the words arnold and palmer in the Title field and print out the Title field and Author of those records. You can mix any number of field specifications with any number of -any options.  

SEE ALSO

qedit(1), qread(1)  

DIAGNOSTICS

query exits with an exit status of 1 if any error occurs and an exit status of 0 otherwise. This is sufficient to cause TK scripts using query to display an informative error box if an error occurs.

If the -print option is not used, then empty rows are printed.  

BUGS

Standard QDDB operations such as or and not, and search types such as regular expressions, string ranges, numeric ranges, and substrings, are not yet implemented in query.  

REFERENCES

A Guide to QDDB
Eric H. Herrin II and Raphael A. Finkel

Qddb User's Guide

An ASCII Database for Fast Queries of Relatively Stable Data
Eric H. Herrin II and Raphael A. Finkel
Computing Systems, Volume 4 Number 2
University of California Press, Berkeley CA

Schema and Tuple Trees: An Intuitive Structure for 
Representing Relational Data
Eric H. Herrin, II and Raphael A. Finkel
Computing Systems, Volume 9, Number 2
MIT Press, Cambridge MA


 

Index

NAME
SYNOPSIS
DESCRIPTION
HUMAN READABLE OUTPUT
INTERFACING WITH TCL
SEARCH ALGORITHM
SEE ALSO
DIAGNOSTICS
BUGS
REFERENCES

This document was created by man2html, using the manual pages.
Time: 18:55:30 GMT, October 31, 2018