Content-type: text/html; charset=UTF-8
query Relation [-tcl [-norows]] [-sep 'field separator'] [-any Value ...] [AttributeName Value ...] [-print AttributeName[:Width] ...]
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.
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 ISBNmight 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:12would 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.
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:12and 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.
$ query Books -any 'arnold palmer' -print Titlewill 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 Authorwill 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.
If the -print option is not used, then empty rows are printed.
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