show

Synopsis

void show(string)
void show(set)

Description

Show is a function useful primarily during interactive use of QL. In its first form it will show, for a given string, all information the factbase contains about it - the entries in all relations (esets) that either begin or end at that string, as well as any attributes that string may have. In its second form, it will display that information for all items in a set.

Example

Consider a factbase with two relations: madeOf and consume:

>> madeOf
pizza meat
pizza pineapple
pizza cheese
sandwich meat
sandwich cheese
sandwich bread
hamburger meat
bread flour
>> consume
johnny pizza
johnny sandwich
johnny hamburger
johnny bread
tony pizza
tony sandwich
tony hamburger
tony bread
Items "bread" and "pizza" also have attributes, as follows:
>> @label
pizza Hawaiian
bread French
>> @price
pizza $11.99
bread $3.99

The relations describe that pizza, hamburger, sandwich and bread are made out of a variety of ingredients, and that johnny and tony consume all the foods in the domain of the madeOf relation.

If we want to find out how, for example, bread interacts with other entities in our fact base, we can use the show command:

>> show ("bread")
bread :  { label=French price=$3.99 }
   ( consume <- johnny )
   ( consume <- tony )
   ( madeOf -> flour )
   ( madeOf <- sandwich )
This tells us that two edges in the consume relation go to "bread"--one from johnny and one from tony. Bread also appears in two tuples in the madeOf relation, once as the source of an edge, going to flour, and once as the target of an edge, going from sandwich. All attributes of bread (its price and label) are also shown.

If we want to generate an extended report on both bread and pizza, we can use the second form of the show command, which accepts a set as an argument. We build a set consisting of "bread" and "pizza" and pass it to show:

>> show ({"bread", "pizza"})
bread : { label=French price=$3.99 }
   ( contain <- sandwich )
   ( consume <- johnny )
   ( consume <- tony )
   ( madeOf -> flour )
   ( madeOf <- sandwich )
 
pizza : { label=Hawaiian price=$11.99 }
   ( consume <- johnny )
   ( consume <- tony )
   ( madeOf -> meat )
   ( madeOf -> pineapple )
   ( madeOf -> cheese )

Special relations

Some relations are treated specially by the show command. When showing an entity that participates in these special relations, the output generated differs from what has been described above. We have already seen an example of this behaviour when discussing attributes, which are just relations beginning with the "@" symbol. There are three others: contain, $INSTANCE and @name.

The relation named "contain", if it exists, is treated specially by the show command (and by several others: !!!TODO!!!: which ones?). The output for those tuples where string is the origin is presented in a special format, and the name of the relation is omitted, because it is assumed to be contain.

The relation "$INSTANCE", if it exists, is also treated specially--the tuples from this relation do not appear in the normal relation report. Instead, if $INSTANCE contains an edge that goes from the parameter to show to some other string, that string is shown in the report.

Finally the parameter "name" (which corresponds to the relation @name) is also treated specially. It is not shown together with the other parameters. Instead, if the parameter is defined for the string which has been passed as a parameter to show, it is displayed separately. If strings that participate in relations with the parameter to show have a name defined, their names will be shown in the relation report.

Strings that occur in the range of the $INSTANCE relation or in the range of any relation starting with the "@" symbol (a parameter) and nowhere else are ignored by show; if you invoke show on such a string, it will be treated as if it is not present in the factbase.

The example below illustrates all the special relations discussed above. Here we create a "contain" relation (equivalent to the madeOf relation), an "$INSTANCE" relation, and define names for some of the entities involved; the output of the show command then changes accordingly.

>> contain = madeOf
>> @name = {"bread"} X {"faxseed_rye"} + {"sandwich"} X {"house_special"} + {"flour"} X {"RobinHood_brand"}
>> $INSTANCE =  {"bread"} X {"food"} + {"sandwich"} X {"dish"} + {"flour"} X {"ingredient"}
>> show ("bread")
faxseed_rye : food @ bread { label=French price=$3.99 }
   ( contain <- house_special @ sandwich )
   ( madeOf -> RobinHood_brand @ flour )
   ( madeOf <- house_special @ sandwich )
   ( consume <- johnny )
   ( consume <- tony )
|  RobinHood_brand @ flour
Note the last line; it corresponds to the tuple in the newly created "contain" relation which speaks of bread containing flour. The name of the relation is not mentioned because contain is the default relation. Notice also that while there is a tuple in the contain relation showing that sandwich contains bread, it is not listed, because in this tuple "bread" is destination of the edge, and not the origin.

See also

showedge showtree showpath