SNePSUL DBMS Demonstration
Using SNePS as a Relational Database Management System

Back to SNeRG home page.
Date and time run:February 15, 2008, 4:05 PM EST
Version:SNePS 2.7
Platform:nickelback.cse.buffalo.edu
Description:Sun Sunfire X4200 with 8.0 GB of main memory and 4 Dual Core AMD Opteron (tm) Processor 285s, clocked at 2592 MHz.
Operating System:RedHat Enterprise Linux 4 (64-bit)
Language:International Allegro CL Enterprise Edition 8.1 [Linux (x86)] (Oct 16, 2007 16:39)
 Copyright (C) 1985-2007, Franz Inc., Oakland, CA, USA. All Rights Reserved.
 Optimization settings: safety 1, speed 3, space 0, and debug 0.

   Welcome to SNePS-2.7 [PL:0 2007/10/13 21:05:28]

Copyright (C) 1984--2007 by Research Foundation of
State University of New York. SNePS comes with ABSOLUTELY NO WARRANTY!
Type `(copyright)' for detailed copyright information.
Type `(demo)' for a list of example applications.

   2/15/2008 16:05:00

* (demo)
Available demonstrations:
   1:  DBMS - Using SNePS as a relational database
   2:  UVBR - Demonstrating the Unique Variable Binding Rule
   3:  The Jobs Puzzle - A solution with the Numerical Quantifier
   4:  Meeting - A numerical quantifier example about people in meetings
   5:  Mother - A numerical quantifier example about the mother relation
   6:  Owner - A numerical quantifier example about dog owners
   7:  SNeRE - A demo of the SNePS Rational Engine
   8:  ARC/SNACTor - Connecting ARC/INFO and SNeRE (previously SNACTor)
   9:  Q&A - Using SNaLPS for simple natural language question answering
  10:  Parse Trees - Using SNaLPS to produce parse trees
  11:  Pegasus - Why winged horses lead to contradictions
  12:  Contextual Vocabulary Acquisition: forming a definition for 'brachet'
  13:  Enter a demo filename
Your choice (q to quit): 1

File /projects/snwiz/Install/Sneps-2.7.0/demo/dbms/dbmsdemo.sneps is now the source of input.

  The demo will pause between commands, at that time press
  RETURN to continue, or ? to see a list of available commands


 CPU time : 0.01 

* ; Database example from Date, Third Edition, Vol. 1, Figure 6.2
;
(resetnet t)
--- pause ---c

Net reset


 CPU time : 0.00 

* ;
(define snum sname status city
        pnum pname color weight
        jnum jname qty)

(snum sname status city pnum pname color weight jnum jname qty)

 CPU time : 0.00 

* ;
(assert snum s1 sname smith status \20 city london)

(m1!)

 CPU time : 0.00 

* ;
^ 
--> 
(defsnepscom s ((snum sname status city))
  #!((assert snum ~snum sname ~sname status ~status city ~city)))
t



 CPU time : 0.00 

* ;
(s s2 jones \10 paris)

(m2!)

 CPU time : 0.00 

* (s s3 blake \30 paris)

(m3!)

 CPU time : 0.00 

* (s s4 clark \20 london)

(m4!)

 CPU time : 0.00 

* (s s5 adams \30 athens)

(m5!)

 CPU time : 0.00 

* ;
^

--> (defsnepscom p ((pnum pname color weight city))
  #!((assert pnum ~pnum pname ~pname color ~color
	     weight ~weight city ~city)))
t



 CPU time : 0.00 

* ;
(p p1 nut red \12 london)

(m6!)

 CPU time : 0.00 

* (p p2 bolt green \17 paris)

(m7!)

 CPU time : 0.01 

* (p p3 screw blue \17 rome)

(m8!)

 CPU time : 0.00 

* (p p4 screw red \14 london)

(m9!)

 CPU time : 0.00 

* (p p5 cam blue \12 paris)

(m10!)

 CPU time : 0.00 

* (p p6 cog red \19 london)

(m11!)

 CPU time : 0.02 

* ;
^

--> (defsnepscom j ((jnum jname city))
  #!((assert jnum ~jnum jname ~jname city ~city)))
t



 CPU time : 0.00 

* ;
(j j1 sorter paris)

(m12!)

 CPU time : 0.00 

* (j j2 punch rome)

(m13!)

 CPU time : 0.00 

* (j j3 reader athens)

(m14!)

 CPU time : 0.00 

* (j j4 console athens)

(m15!)

 CPU time : 0.00 

* (j j5 collator london)

(m16!)

 CPU time : 0.00 

* (j j6 terminal oslo)

(m17!)

 CPU time : 0.00 

* (j j7 tape london)

(m18!)

 CPU time : 0.00 

* ;
^

--> (defsnepscom spj ((snum pnum jnum qty))
  #!((assert snum ~snum pnum ~pnum jnum ~jnum qty ~qty)))
t



 CPU time : 0.00 

* ;
(spj s1 p1 j1 \200)

(m19!)

 CPU time : 0.00 

* (spj s1 p1 j4 \700)

(m20!)

 CPU time : 0.00 

* (spj s2 p3 j1 \400)

(m21!)

 CPU time : 0.00 

* (spj s2 p3 j2 \200)

(m22!)

 CPU time : 0.00 

* (spj s2 p3 j3 \200)

(m23!)

 CPU time : 0.00 

* (spj s2 p3 j4 \500)

(m24!)

 CPU time : 0.00 

* (spj s2 p3 j5 \600)

(m25!)

 CPU time : 0.00 

* (spj s2 p3 j6 \400)

(m26!)

 CPU time : 0.00 

* (spj s2 p3 j7 \800)

(m27!)

 CPU time : 0.00 

* (spj s2 p5 j2 \100)

(m28!)

 CPU time : 0.00 

* (spj s3 p3 j1 \200)

(m29!)

 CPU time : 0.00 

* (spj s3 p4 j2 \500)

(m30!)

 CPU time : 0.00 

* (spj s4 p6 j3 \300)

(m31!)

 CPU time : 0.00 

* (spj s4 p6 j7 \300)

(m32!)

 CPU time : 0.00 

* (spj s5 p2 j2 \200)

(m33!)

 CPU time : 0.00 

* (spj s5 p2 j4 \100)

(m34!)

 CPU time : 0.00 

* (spj s5 p5 j5 \500)

(m35!)

 CPU time : 0.00 

* (spj s5 p5 j7 \100)

(m36!)

 CPU time : 0.00 

* (spj s5 p6 j2 \200)

(m37!)

 CPU time : 0.00 

* (spj s5 p1 j4 \1000)

(m38!)

 CPU time : 0.00 

* (spj s5 p3 j4 \1200)

(m39!)

 CPU time : 0.00 

* (spj s5 p4 j4 \800)

(m40!)

 CPU time : 0.00 

* (spj s5 p5 j4 \400)

(m41!)

 CPU time : 0.00 

* (spj s5 p6 j4 \500)

(m42!)

 CPU time : 0.01 

* ;
; Database Queries from Date, Third Edition, Vol. 1, Exercises 7.1-34
;
; 7.1  Get full details of all projects.
;
(dump (find jname ?x))

(m18! (city (london) jname (tape) jnum (j7)))
(m17! (city (oslo) jname (terminal) jnum (j6)))
(m16! (city (london) jname (collator) jnum (j5)))
(m15! (city (athens) jname (console) jnum (j4)))
(m14! (city (athens) jname (reader) jnum (j3)))
(m13! (city (rome) jname (punch) jnum (j2)))
(m12! (city (paris) jname (sorter) jnum (j1)))

(m18! m17! m16! m15! m14! m13! m12!)

 CPU time : 0.00 

* ;
; 7.2  Get full details of all projects in London.
;
(dump (find jname ?x city london))

(m16! (city (london) jname (collator) jnum (j5)))
(m18! (city (london) jname (tape) jnum (j7)))

(m16! m18!)

 CPU time : 0.00 

* ;
; 7.3  Get the part number for parts such that no other part
;      has a smaller weight value.
;
(find (pnum- weight) (dbmin (find weight- ?x)))

(p5 p1)

 CPU time : 0.00 

* ;
; 7.4  Get S# values for supliers who supply project J1.
;
(find (snum- jnum) j1)

(s3 s2 s1)

 CPU time : 0.00 

* ;
; 7.5  Get S# values for suppliers who supply project J1 with part P1.
;
(find snum- (find jnum j1 pnum p1))

(s1)

 CPU time : 0.00 

* ;
; 7.6  Get JNAME values for projects supplied by supplier S1.
;
(find (jname- jnum jnum- snum) s1)

(console sorter)

 CPU time : 0.00 

* ;
; 7.7  Get COLOR values for parts supplied by supplier S1.
;
(find (color- pnum pnum- snum) s1)

(red)

 CPU time : 0.00 

* ;
; 7.8  Get S# values for suppliers who supply both projects J1 and J2.
;
(find (snum- jnum) j1 (snum- jnum) j2)

(s3 s2)

 CPU time : 0.00 

* ;
; 7.9  Get S# values for suppliers who supply project J1 with a red part.
;
(find snum- (find jnum j1 (pnum pnum- color) red))

(s1)

 CPU time : 0.00 

* ;
; 7.10  Get P# values for parts supplied to any project in London.
;
(find (pnum- jnum jnum- city) london)

(p6 p5 p3)

 CPU time : 0.00 

* ;
; 7.11  Get S# values for suppliers who supply a London or Paris
;       project with a red part.
;
(find snum- (find (jnum jnum- city) (london paris) (pnum pnum- color) red))

(s1 s4)

 CPU time : 0.00 

* ;
; 7.12  Get P# values for parts supplied to any project by
;       a supplier in the same city.
;
(find pnum- (find jnum (find jnum- (find city ?city))
                  snum (find snum- (find city ?city))))

(p3 p6 p5 p4 p3 p1 p2 p6)

 CPU time : 0.00 

* ;
; 7.13  Get P# values for parts supplied to any project in London
;       by a supplier in London.
;
(find pnum- (find (jnum jnum- city) london (snum snum- city) london))

(p6)

 CPU time : 0.00 

* ;
; 7.14  Get J# values for projects supplied by at least one
;       supplier not in the same city.
;
(find jnum- (find qty ?any) - (find (jnum jnum- city) ?city
                                    (snum snum- city) ?city))

(j1 j4 j6 j3 j5 j7 j2)

 CPU time : 0.00 

* ;
; 7.15  Get J# values for projects not supplied with any red part
;       by any London supplier.
;
(- (find jnum- ?x) (find jnum- (find (pnum pnum- color) red
                                     (snum snum- city) london)))

(j6 j5 j2)

 CPU time : 0.00 

* ;
; 7.16  Get S# values for suppliers supplying at least one part supplied by
;       at least one supplier who supplies at least one red part.
;
(find (snum- pnum pnum- snum snum- pnum pnum- color) red)

(s3 s4 s2 s5 s1)

 CPU time : 0.00 

* ;
; 7.17  Get J# values for projects using at least one part
;       available from supplier S1.
;
(find (jnum- pnum pnum- snum) s1)

(j4 j1)

 CPU time : 0.00 

* ;
; 7.18  Get all pairs of CITY values such that a supplier in the
;       first city supplies a project in the second city.
;
(define city1 city2)

(city1 city2)

 CPU time : 0.00 

* ;
(define-path city1 (compose snum snum- city)
             city2 (compose jnum jnum- city))
city1 implied by the path (compose snum snum- city)
city1- implied by the path (compose city- snum snum-)
city2 implied by the path (compose jnum jnum- city)
city2- implied by the path (compose city- jnum jnum-)


 CPU time : 0.00 

* ;
(dbproject (find qty ?q) city1 city2)

((city1 (athens) city2 (athens)) (city1 (athens) city2 (rome))
 (city1 (athens) city2 (london)) (city1 (london) city2 (london))
 (city1 (london) city2 (athens)) (city1 (paris) city2 (rome))
 (city1 (paris) city2 (paris)) (city1 (paris) city2 (london))
 (city1 (paris) city2 (oslo)) (city1 (paris) city2 (athens))
 (city1 (london) city2 (paris)))

 CPU time : 0.01 

* ;
; 7.19  Get all  triples such that a supplier in the first city
;       supplies the specified part to a project in the second city.
;
(dbproject (find qty ?q) city1 pnum city2)

((city1 (athens) pnum (p6) city2 (athens))
 (city1 (athens) pnum (p5) city2 (athens))
 (city1 (athens) pnum (p4) city2 (athens))
 (city1 (athens) pnum (p3) city2 (athens))
 (city1 (athens) pnum (p1) city2 (athens))
 (city1 (athens) pnum (p6) city2 (rome))
 (city1 (athens) pnum (p5) city2 (london))
 (city1 (athens) pnum (p2) city2 (athens))
 (city1 (athens) pnum (p2) city2 (rome))
 (city1 (london) pnum (p6) city2 (london))
 (city1 (london) pnum (p6) city2 (athens))
 (city1 (paris) pnum (p4) city2 (rome))
 (city1 (paris) pnum (p3) city2 (paris))
 (city1 (paris) pnum (p5) city2 (rome))
 (city1 (paris) pnum (p3) city2 (london))
 (city1 (paris) pnum (p3) city2 (oslo))
 (city1 (paris) pnum (p3) city2 (athens))
 (city1 (paris) pnum (p3) city2 (rome))
 (city1 (london) pnum (p1) city2 (athens))
 (city1 (london) pnum (p1) city2 (paris)))

 CPU time : 0.00 

* ;
; 7.20  Repeat Exercise 7.19, but do not retrieve triples in which
;       the two CITY values are the same.
;
(dbproject (- (find qty ?q) (find city1 ?c city2 ?c)) city1 pnum city2) 

((city1 (athens) pnum (p6) city2 (rome))
 (city1 (athens) pnum (p5) city2 (london))
 (city1 (athens) pnum (p2) city2 (rome))
 (city1 (london) pnum (p6) city2 (athens))
 (city1 (paris) pnum (p4) city2 (rome)) (city1 (paris) pnum (p5) city2 (rome))
 (city1 (paris) pnum (p3) city2 (london))
 (city1 (paris) pnum (p3) city2 (oslo))
 (city1 (paris) pnum (p3) city2 (athens))
 (city1 (paris) pnum (p3) city2 (rome))
 (city1 (london) pnum (p1) city2 (athens))
 (city1 (london) pnum (p1) city2 (paris)))

 CPU time : 0.00 

* 
;
; 7.21 Get S# values for suppliers who supply the same part to all projects.
;
(find jnum- ?x)

(j7 j6 j5 j4 j3 j2 j1)

 CPU time : 0.01 

* ;
(find snum- (find pnum ?p jnum j1)
      snum- (find pnum ?p jnum j2)
      snum- (find pnum ?p jnum j3)
      snum- (find pnum ?p jnum j4)
      snum- (find pnum ?p jnum j5)
      snum- (find pnum ?p jnum j6)
      snum- (find pnum ?p jnum j7))

(s2)

 CPU time : 0.00 

* ;
; 7.22  Get J# values for projects supplied entirely by supplier S1.
;
(- (find (jnum- snum) s1)
   (find (jnum- snum) (find snum- ?x) - s1))


 CPU time : 0.00 

* ;
; 7.23 Get P# values for parts supplied to all projects in London.
;
(find (jnum- city)  london)

(j7 j5)

 CPU time : 0.00 

* ;
(find (pnum- jnum) j5 (pnum- jnum) j7)

(p5 p3)

 CPU time : 0.00 

* ;
; 7.24  Get J# values for projects supplied with at least all parts
;       supplied by supplier S1.
;
(find (pnum- snum) s1)

(p1)

 CPU time : 0.00 

* ;
(find (jnum- pnum) p1)

(j4 j1)

 CPU time : 0.00 

* ;
; 7.25 Get J# values for projects which use only parts which are
;      available from supplier S1.
;
(- (find jnum- (find qty ?q))
   (find (jnum- pnum)
         (find pnum- ?r) - (find (pnum- snum) s1)))


 CPU time : 0.00 

* ;
; 7.26  Get J# values for projects supplied by supplier S1 with all parts that
;       supplier S1 supplies.
;
(find (pnum- snum) s1)

(p1)

 CPU time : 0.00 

* ;
(find jnum- (find snum s1 pnum p1))

(j4 j1)

 CPU time : 0.00 

* ;
; 7.28  Get J# values for projects supplied by all suppliers who supply some
;       red part.
;
(find (snum- pnum pnum- color) red)

(s4 s3 s5 s1)

 CPU time : 0.00 

* ;
(find (jnum- snum) s1
      (jnum- snum) s3
      (jnum- snum) s4
      (jnum- snum) s5)


 CPU time : 0.00 

* ;
; 7.29  Change the name of project J6 to 'VIDEO'.
(erase (find jnum j6 city ?c))

(m17 city (oslo) jname (terminal) jnum (j6))
node dismantled. 


 CPU time : 0.00 

* ;
(describe (assert jnum j6 jname video city *c))

(m43! (city oslo) (jname video) (jnum j6))

(m43!)

 CPU time : 0.00 

* ;
; 7.30  Change the color of all red parts to orange.
;
(dump (find color red))

(m6! (city (london) color (red) pname (nut) pnum (p1) weight (12)))
(m9! (city (london) color (red) pname (screw) pnum (p4) weight (14)))
(m11! (city (london) color (red) pname (cog) pnum (p6) weight (19)))

(m6! m9! m11!)

 CPU time : 0.00 

* ;
(p p1 nut orange \12 london)

(m44!)

 CPU time : 0.00 

* ;
(p p4 screw orange \14 london)

(m45!)

 CPU time : 0.00 

* ;
(p p6 cog orange \19 london)

(m46!)

 CPU time : 0.00 

* ;
(erase (find color red))

(m6 city (london) color (red) pname (nut) pnum (p1) weight (12))
node dismantled. 

(m9 city (london) color (red) pname (screw) pnum (p4) weight (14))
node dismantled. 

(m11 city (london) color (red) pname (cog) pnum (p6) weight (19))
node dismantled. 


 CPU time : 0.02 

* ;
; 7.31  Delete all red parts and the corresponding SPJ records.
;
(erase (find (pnum pnum- color) red))


 CPU time : 0.00 

* ;
; 7.32  Get the total number of projects supplied by supplier S3.
;
(dbcount (find (jnum- snum) s3))

(2)

 CPU time : 0.00 

* ;
; 7.33 Get the total quantity of part P1 supplied by supplier S1.
;
(dbtot (find qty- (find pnum p1 snum s1)))

(900)

 CPU time : 0.00 

* ;
; Clean up, so the special demo commands won't clutter up the environment:
;
(^ (undefsnepscoms s p j spj))

(t)

 CPU time : 0.00 

* 

End of /projects/snwiz/Install/Sneps-2.7.0/demo/dbms/dbmsdemo.sneps demonstration.


 CPU time : 0.10 

Back to SNeRG home page.
Last modified: Fri Feb 15 16:07:34 EST 2008
Stuart C. Shapiro <shapiro@cse.buffalo.edu>