$base B ~ - B database unequal anything (is empty).
Left sentences are Z statements, right sentences - literal translation.
The B name of the current database may be missing. Database type
is specified by base key word immediately after $.
< Tests multibase working > $base ~ ; < Clears current base > < Z statements >; ... $base "Sample/OldBase"; < Z statements >; ... $base "Sample/NewBase" ~ ; < Z statements >; ...The < ... > construction is a comment in Z.
Considered auxiliary structure:
{a1, …} - a set, a1, … .
For example A: { a1, a2 }, or equal {A: a1, A: a2}.S* . S denotes sequence of non key symbols.
For example a* in place of { a1, a2, ... an }.
note workfellow telephone address #1 Ringer Michael 415 506-0111 4 Broadway Av 503 743-5226 #2 Smith Anne 400 297-0752 10 Seventh Av Smith RobertLet's create Ex/Interpreter/RelDB database.
$base "Ex/Interpreter/RelDB" ~;Now input the table information. Description of schema, first statement, is optional!!!. Z DBMS deduces schema automatically.
note (workfellow, telephone, address); note: #1 (workfellow: Ringer Michael, telephone: { 415 506-0111, 503 743-5226 }, address: 4 Broadway Av); note: #2 (w*: Smith Anne, w*: Smith Robert, t*: 400 297-0752, a*: 10 Seventh Av);
For example:= { … =/~/, … } - the set of the ... and/no/or the ... .
= R: - anything equal to the R class;
= R: (A: a) - the R class namely relation of the A: a ;
= (A: a, B: b) - the relation of the A: a and B: b ;
= ( { A: a, B: b } ) - the relation of the A: a or B: b .
For example: = { R: ~ (B: ) } - anything of the R class no the relation of the B class.= A: a ^ b - the A class namely range from a to b.
Z has unique features: class name may be absent or retrieved by the
query. For example = : a denotes all the a of arbitrary class.
The order of the class name and class value is not crucial in the query
that begins with ':' symbol, for example = : a: A in place of =
A: a.
= tel*: 415* ^;Result in the Report window:
telephone ( note ):{ 415 506-0111 ( note:#1 ), 503 743-5226 ( note:#1 ) };We can image relations with 4* address and with one of the 4* telephones. Attribute name, tel*, put after attribute value, for testing.
= (addr*: 4*, : 4*: tel*);Result:
note ( address, telephone, workfellow ):#1 ( address:4 Broadway Av, telephone:{ 415 506-0111, 503 743-5226 }, workfellow:Ringer Michael );Finally output all the notes that have relation with 4* telephone, but no relation with 503* instance.
= { note: (tel*: 4*) ~ (: 503*) }; ----- note ( address, telephone, workfellow ):#2 ( address:10 Seventh Av, telephone:400 297-0752, workfellow:{ Smith Anne, Smith Robert } );
A B A ^ B A : B A / B = A A ~ B A = B A , B A ; B |
All the complete expressions, separated by the ';', are statements. Expression may be description, query, or procedure. If Z expression begins with = symbol, this expression is a query. For example: = Q is a query, whereas D (D1) is description. Description inside of the query should be ended with =. For example: = { D = }. For the ~ operator the operands are queries, Q ~ Q1 , Q ~ .
We can use: print, printLine, printRelation, printClass, printName,
or a contraction thereof p, pl, pr, pc, pn. The F is an output
file. Missing of the $file parameter denotes output in the Report
window. The Q, … are queries or "…" strings. If Q parameters are absent
in printRelation, printClass, or printName it assumes
printing all the database's relations, classes, or names correspondingly.
$p("SCHEMA OF ");
$p(*);
$pl();
$pl("------------------------------------------------------");
$pr(*);
SCHEMA OF address, note, telephone, workfellow ------------------------------------------------------ address ( note ), note ( address, telephone, workfellow ), telephone ( note ), workfellow ( note );The $Content: service class is useful. It is formed by the system itself and can help to print the "head relations".
$pl("CONTENT OF RelDB DATABASE"); $pl("------------------------------------------------------"); $pr($Content: );The fragment produces in Report window the following result.
CONTENT OF RelDB DATABASE ------------------------------------------------------ $Content:note ( address, telephone, workfellow );If you want to print contents of the workfellow class relating with the notes of the 415* telephone in the Ex/Interpreter/wf415.txt, type
$pc($file "Ex/Interpreter/wf415.txt", workf*: (note: (telephone: 415*) ) );If you need save all the database's names in the Ex/Interpreter/names.txt, type
$pn($file "Ex/Interpreter/names.txt");
{ … } ~ (A: a, …) - a set, the …, is not equal to relation of the A class a and …. The {…} (~ …) is not correct!
R: #N - R class namely N number. Here N
is positive number, 1073741823 maximum by default.
Look at the R: # expression. The indefinite number is last number
if the R: # query, and is new number if the R: # description.
Notice that R = : R1 construction is the same as R1, R: R1
sequence,
R ~ : R1 is the same as R: R1 ~. If value of the
=
: r query is not available, the
: r = description equals
r. The R: = description entails R if the = R:
query is not available.
note: (: Smith*) ~ (: Smith Anne); note: # (: Smith Anne); { = note: # } (t*: 503 743-5226); Take a look at the result using
= (: Smith*);
note ( address, telephone, workfellow ):{ #2 ( address:10 Seventh Av, telephone:400 297-0752, workfellow:Smith Robert ), #3 ( telephone:503 743-5226, workfellow:Smith Anne ) };
R: r ~ ( ) - R class namely r is not relation. Deletes relations.
R: r ~ - R class namely r is not. Deletes concepts.
$pr(note: #3); note: { =#3 = =(: Ringer*) }; $pr(note: #3); : Ringer* ~; $pr(note: #3); note: #1 ~ ( ); $pr(note: );
note:#3 ( telephone:503 743-5226, workfellow:Smith Anne ) note:#3 ( address:4 Broadway Av, telephone:{ 415 506-0111, 503 743-5226 }, workfellow:{ Ringer Michael, Smith Anne } ); note:#3 ( address:4 Broadway Av, telephone:{ 415 506-0111, 503 743-5226 }, workfellow:Smith Anne ); note:{ #1, #2 ( address:10 Seventh Av, telephone:400 297-0752, workfellow:Smith Robert ), #3 ( address:4 Broadway Av, telephone:{ 415 506-0111, 503 743-5226 }, workfellow:Smith Anne ) };
$readTable($file "F1", R1, N0, N1, …) - read table from F1 file in R1 relation with column numbers N0 key, N1, …).
If F0 file parameter is missing Report window is suggested. R1 is name description of a class relation. The A0, A1, … may be queries. The procedures has name contractions pt for printTable, rt for readTable. If the A0, A1, … are absent, all the attributes, the R0 has, will be output in alphabet order. If there are not N0, N1, …, all the columns will be input.
A first input line of F1 file must define the names of columns.
Delimiter
of the table fields may be only semicolon ";". Values of the field are
separated by the ','. The words with the $ * # " ' { [ ( } ] ) ^ : / \
~ = , ; < > key symbols need be enclosed in the quotes. The price
may be without quotes, $10.2. Distinction of the "..." and
'...'
see in the next section.
$pt($file "Ex/Interpreter/Note.tab", note:); $base "Ex/Interpreter/ObjDB" ~; $rt($file "Ex/Interpreter/Note.tab", #4, #2, #3); $pt($file "Ex/Interpreter/Workfellow.tab", workfellow: ); $pt(workfellow:, workfellow, telephone, address);
workfellow; telephone; address Smith Anne; 415 506-0111, 503 743-5226; 4 Broadway Av Smith Robert; 400 297-0752; 10 Seventh Av
Here S is any sequence of symbols. Notice that "S" name and #N number may end up space combination, for example R "S", whereas "S" R and "S" "S1" are not correct. System tests existing "S" and #N concepts in a database only when need test its connection or equality. For example "S" will be tested if "S": or = "S" , but not if { "S" } or $print("S") .
Single quotes may be helpful only for using special symbols, for instance
R:
'*'. Using R: "S", as R: #N, reduces the required size
and accelerates running, but a price must be paid in loss of the contractions,
:"S",
: #N . It may be fit for a big database.
$base "Ex/Interpreter/Test" ~; office: '#10' (employer: #1, company: "Unknown"); = office: ''*; = employer: #*; = company: "U"*; = { "Attainable" }; = : '#10';Derivable result:
office ( company, employer ):'#10' ( company:"Unknown", employer:#1 ); employer ( office ):#1 ( office:'#10' ); company ( office ):"Unknown" ( office:'#10' ); "Attainable"; office ( company, employer ):'#10' ( company:"Unknown", employer:#1 );Following fragment produces Failure messages.
= "Unattainable"; = : #1; = : "Unknown";