To explain the output, comments are placed in italics throughout the page.
LEAP - An Extendable Relational Algebra Processor. Beta Version #0.10.0d Copyright (c) Richard Leyton 1994,1996. Ver.Date 19th February 1996 888 8888888888 d8888 8888888b. 888 888 d88888 888 Y88b 888 888 d88P888 888 888 888 8888888 d88P 888 888 d88P 888 888 d88P 888 8888888P" 888 888 d88P 888 888 888 888 d8888888888 888 88888888 8888888888 d88P 888 888 Starting. This is LEAP - Beta Version #0.10.0d Please feel free to distribute this version of LEAP. For warranty/conditions, type INFO at the prompt. Do not continue to use LEAP if you do not accept the conditions. Changes in this version: * Numeric Data types supported. * Hashing tables maintained between runs. * New data format for relations. Old formats are still supported. * Tuple duplicates are not permitted. * Multiple databases. * Data Dictionary * Data cache Press any key to continue.This is the opening screen, now things start happening...
Opening MASTER database... This is the master database... --- Retrieving Relations --- LEAPDATA is a LEAP system table! Opening USER database... This is a user [USER] database... --- Retrieving Relations --- Startup sequence initiated. >>high LEAP - An Extendable Relational Algebra Processor. Beta Version #0.10.0d Copyright (c) Richard Leyton 1994,1996. Ver.Date 19th February 1996 >>status LEAP Status =========== Debug Information is off. Infix operators is on. Operation Timing is off. Time format is European File copy is on. Colour is on. Additional IO is off. Case sensitivity is off. Internal Cache is off. Display Parse Tree is off. Iterative Parser is on. Current database is USER Data directory is set to C:\LEAP\DATABASE\USER\RELATION Beta Version #0.10.0d >>@This is the status of LEAP, the best examples are in the stanczyk database, so we change databases...
>use stanczyk Closing database [USER]... Opening database [STANCZYK] -------------------------------------------------------------------------------This database contains examples from Stefan Stanczyk's "Theory and Practice of relational databases", published by Pitman, 1990. -------------------------------------------------------------------------------This database has a number of useful examples that clearly demonstrate the relational algebra. Note in particular ex42, which because of the introduction of numeric data types, the result is as published! >>@What relations exist in this database?
>list Name Temporary? AUCTION X BOOK X BORROW X BRANCH X CLIENT X CUSTOMER X DELIVERY X EXAMPLE X EX_AUTH X EX_BOOK X EX_PUBLI X GOODS X INDEX X LC X NAMES X P3 X Q X R X S X STOCK X SUBJECT XWhat command scripts exist?
>sources DISP_EX EX4_1_A EX4_1_B EX41A EX41B EX42 EX43 EX45 Q4_3_3 Q4_3_4 Q4_3_5 Q431 Q432 Q433 DIVIDE OPEN EX44Whats in script "ex42"...
>l ex42 Listing C:\LEAP\DATABASE\STANCZYK\SOURCE\EX42.SRC ------------------------------------------------- # This example is taken from STA90, and uses infix expressions. # Example 4.2 (page 70) infix y r3=restrict (auction) (sell_price>purchase_price) print r3 @ # LEAP source file - Richard Leyton, 05/06/1995 >print auction Relation: AUCTION REFERENCE DATE_BOUGHT PURCHASE_PRICE DATE_SOLD SELL_PRICE ----------------------------------------------------------------------------------------------------------------------------- R005 17-03-84 25 23-09-86 12.25 R020 02-12-43 4 17-10-88 145.50 R022 09-11-79 7.50 21-11-88 3.25 R048 15-05-68 3.50 16-03-89 8.50 R049 15-05-68 3.50 16-03-89 8.50 R073 21-02-76 18.50 25-03-89 9.25What happens when its run?
>@ ex42 >>infix y Infix operators is on. >>r3=restrict (auction) (sell_price>purchase_price) R3 Returned. >>print r3 Relation: R3 REFERENCE DATE_BOUGHT PURCHASE_PRICE DATE_SOLD SELL_PRICE ----------------------------------------------------------------------------------------------------------------------------- R020 02-12-43 4 17-10-88 145.50 R048 15-05-68 3.50 16-03-89 8.50 R049 15-05-68 3.50 16-03-89 8.50 >>@Here's a simple nested query...
>l ex4_1_a Listing C:\LEAP\DATABASE\STANCZYK\SOURCE\EX4_1_A.SRC ---------------------------------------------------- # This example is taken from DAT90 and uses infix expressions # Exercise 4.1 (a) Page 81 & 159 infix y PROJECT (SELECT (EX_BOOK) (PNAME='PITMAN')) (TITLE) @ # LEAP source file - Richard Leyton, 05/06/1995And a far more complicated one...
>l ex4_1_b Listing C:\LEAP\DATABASE\STANCZYK\SOURCE\EX4_1_B.SRC ---------------------------------------------------- # This example is taken from STA90, and uses infix expressions # Exercise 4.1 (b) Pages 81 & 159 infix y project(join (project( select (ex_book) (pname='mit press'))(aname) ) (ex_auth) (aname=ex_auth.aname)) (specialism) @ # LEAP source file - Richard Leyton, 05/06/1995Run the first one...
>@ ex4_1_a >>infix y Infix operators is on. >>PROJECT (SELECT (EX_BOOK) (PNAME='PITMAN')) (TITLE) LBNUTW Returned. >>@ >print lbnutw Relation: LBNUTW TITLE ------------------------- THEORY AND PRACTICE SQLRun the second one...
>@ ex4_1_b >>infix y Infix operators is on. >>project(join (project( select (ex_book) (pname='mit press'))(aname) ) (ex_auth) (aname=ex_auth.aname)) (specialism) LQYSTQ Returned. >>@ >print lqystq Relation: LQYSTQ SPECIALISM ------------------------- FRENCH LAWBut HOW was it executed? Switch on the parse tree review option!
>parse Display Parse Tree is off. Reverse setting? (Y/N) : Y Display Parse Tree is on.Re-run the more complicated expression...
>@ ex4_1_b >>infix y Infix operators is on. >>project(join (project( select (ex_book) (pname='mit press'))(aname) ) (ex_auth) (aname=ex_auth.aname)) (specialism)And this is quickly displayed...
ROOT NODE Depth: 0 Expression: PROJECT(JOIN (PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) ) (EX_AUTH) (ANAME=EX_AUTH.ANAME)) (SPECIALISM) result:Don't like the automatic relation names? How about this?lresult: rresult: LEFT NODE Depth: 1 Expression: JOIN (PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) ) (EX_AUTH) (ANAME=EX_AUTH.ANAME) result: lresult: rresult: LEFT NODE Depth: 2 Expression: PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) result: lresult: rresult: LEFT NODE Depth: 3 Expression: SELECT (EX_BOOK) (PNAME='MIT PRESS') result: lresult: rresult: LEFT NODE Depth: 4 Expression: EX_BOOK result: lresult: rresult: Returned to Depth: 3 Expression: SELECT (EX_BOOK) (PNAME='MIT PRESS') Returned to Depth: 2 Expression: PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) Returned to Depth: 1 Expression: JOIN (PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) ) (EX_AUTH) (ANAME=EX_AUTH.ANAME) RIGHT NODE Depth: 2 Expression: EX_AUTH result: lresult: rresult: Returned to Depth: 1 Expression: JOIN (PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) ) (EX_AUTH) (ANAME=EX_AUTH.ANAME) Returned to Depth: 0 Expression: PROJECT(JOIN (PROJECT( SELECT (EX_BOOK) (PNAME='MIT PRESS'))(ANAME) ) (EX_AUTH) (ANAME=EX_AUTH.ANAME)) (SPECIALISM) LZZSZB Returned. >>@
>l divide Listing C:\LEAP\DATABASE\STANCZYK\SOURCE\DIVIDE.SRC --------------------------------------------------- # This example is taken from STA90 # Example 4.7 (Page 77) # Divide! Internally, without having to hack files! a1=(lc) product (q) a2=project (a1) (lecturer,subject) rename (a2.subject) (course) a3=(a2) intersect (lc) a4=project (a3)(lecturer) print a4 @ # LEAP source file - Richard Leyton, 20/02/1996 >print lc Relation: LC LECTURER COURSE -------------------------------------------------- BROWN COMPILERS BROWN DATABASES GREEN PROLOG GREEN DATABASES LEWIS PROLOG SMITH DATABASES >print q Relation: Q SUBJECT ------------------------- PROLOG >@ divide >>a1=(lc) product (q) ROOT NODE Depth: 0 Expression: (LC) PRODUCT (Q) result:Right, that's enough for now...lresult: rresult: LEFT NODE Depth: 1 Expression: LC result: lresult: rresult: Returned to Depth: 0 Expression: (LC) PRODUCT (Q) RIGHT NODE Depth: 1 Expression: Q result: lresult: rresult: Returned to Depth: 0 Expression: (LC) PRODUCT (Q) A1 Returned. >>a2=project (a1) (lecturer,subject) ROOT NODE Depth: 0 Expression: PROJECT (A1) (LECTURER,SUBJECT) result: lresult: rresult: LEFT NODE Depth: 1 Expression: A1 result: lresult: rresult: Returned to Depth: 0 Expression: PROJECT (A1) (LECTURER,SUBJECT) A2 Returned. >>rename (a2.subject) (course) ROOT NODE Depth: 0 Expression: RENAME (A2.SUBJECT) (COURSE) result: lresult: rresult: A2 Returned. >>a3=(a2) intersect (lc) ROOT NODE Depth: 0 Expression: (A2) INTERSECT (LC) result: lresult: rresult: LEFT NODE Depth: 1 Expression: A2 result: lresult: rresult: Returned to Depth: 0 Expression: (A2) INTERSECT (LC) RIGHT NODE Depth: 1 Expression: LC result: lresult: rresult: Returned to Depth: 0 Expression: (A2) INTERSECT (LC) A3 Returned. >>a4=project (a3)(lecturer) ROOT NODE Depth: 0 Expression: PROJECT (A3)(LECTURER) result: lresult: rresult: LEFT NODE Depth: 1 Expression: A3 result: lresult: rresult: Returned to Depth: 0 Expression: PROJECT (A3)(LECTURER) A4 Returned. >>print a4 Relation: A4 LECTURER ------------------------- GREEN LEWIS >>@
>quit Closing database [STANCZYK] LEAP - An Extendable Relational Algebra Processor. Beta Version #0.10.0d Copyright (c) Richard Leyton 1994,1996. Ver.Date 19th February 1996 Please send all comments, bugs, suggestions etc. to: richard_leyton@mail.amsinc.com and/or e0190404@brookes.ac.uk Latest version available via anonymous ftp from: ftp.demon.co.uk /pub/compsci/databases/leap micros.hensa.ac.uk /micros/ibmpc/dos/k/k174 sunsite.doc.ic.ac.uk /computing/systems/ibmpc/simtel/msdos oak.oakland.edu /SimTel/msdos/math cmssrv.brookes.ac.uk /pub/databases (See the file location.txt for a list of all locations known containing LEAP) Also WWW at following URL: http://www.brookes.ac.uk/~e0190404/leap.html For warranty and conditions, start LEAP with INFO parameter, or type INFO at the LEAP prompt. Alternatively, see the accompanying documentation for more details. Use of the program implies you have done and accepted this. Pressto continue 888 8888888888 d8888 8888888b. 888 888 d88888 888 Y88b 888 888 d88P888 888 888 888 8888888 d88P 888 888 d88P 888 888 d88P 888 8888888P" 888 888 d88P 888 888 888 888 d8888888888 888 88888888 8888888888 d88P 888 888