From crabapple.srv.cs.cmu.edu!cantaloupe.srv.cs.cmu.edu!rochester!udel!darwin.sura.net!spool.mu.edu!umn.edu!math.fu-berlin.de!informatik.tu-muenchen.de!LRZnews!sun1!ue701af Wed Sep 30 23:16:06 EDT 1992
Article: 6286 of comp.lang.prolog
Newsgroups: comp.lang.prolog
Path: crabapple.srv.cs.cmu.edu!cantaloupe.srv.cs.cmu.edu!rochester!udel!darwin.sura.net!spool.mu.edu!umn.edu!math.fu-berlin.de!informatik.tu-muenchen.de!LRZnews!sun1!ue701af
From: ue701af@sun1.LRZ-Muenchen.DE ()
Subject: Prolog to SQL Compiler version 1.0
Message-ID: <ue701af.717546498@sun1>
Sender: news@news.lrz-muenchen.de (Mr. News)
Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
Date: Sat, 26 Sep 1992 22:28:18 GMT
Lines: 1124


Hi there in netland,

I have now finished the first release of my Prolog to SQL compiler. It
translates database access requests, which consist of a projection term
and a database goal to the appropriate SQL query. This compiler may
be useful in Prolog-to-RDBMS interfaces, which often allow SQL queries
as string arguments (e.g. the Quintus Prolog Oracle interface and others).

The compiler is written in standard Edinburgh Prolog. It has been ported
to a number of Prologs both on the Mac and on UNIX machines - the code
given here works for ECRC's SEPIA Prolog. Other Prologs require a little
modification in the gensym/2 predicates (Quintus Prolog has them in the
library strings, LPA MacProlog has them as built-ins, other Prologs do
not have global variables and thus require assert/1 and retract/1 for
the implementation of gensym/2) - but this is the only place where the
code had to be adapted.

Some specific details on the compiler:

 - it is very powerful in that it allows negation, arithmetics,
   and aggregate functions
 - it is fast (approx. 6 ms in Quintus Prolog on a Sparc)
 - and the code is very clean (no tricks, no secrets...)

Furthermore, a report on the implementation is available (with loads of
benchmarks, motivation, and references to further reading). To receive a 
copy of the report, mail to the following address:

   draxler@sun1.cis.uni-muenchen.de

and give your full postal address. 

Note that there is a copyright on the compiler - however, it may be used
and distributed free of charge for non-commercial purposes and provided 
that the copyright notice is not changed.

How to use the compiler? 

Five sample queries are included in the code, so you consult the file,
and run the goal:

 ?- benchmark(1,N,D).

This evaluation returns the execution time D for one run (first arg) of
query number N. Backtracking will bind N to 2,3,4, and 5 and return the
corresponding runtimes.

A second way to run the compiler is to call it with the goal translate/3:
e.g.

   ?- translate(plane(Type,Seats),plane(Type,Seats),SQLQuery).

translates to an SQL query which retrieves all planes from a given 
relation PLANE. Note that only the two relations flight/4 and plane/2
are defined - roll your own by simply adding them to the meta-database
section in the code (or keep it in a separate file).

I would very much appreciate comments, suggestions for improvements,
and criticism - feel free to mail me. See the introductory remarks in the
commented code for details...

So, have fun (let me know how you did)...

Christoph Draxler

draxler@sun1.cis.uni-muenchen.de


-----------------------------------------------------------------------------

CIS Centre for Information and Language Processing
Ludwig-Maximilians-University Munich
Leopoldstr. 139
D 8000 Munich 40

Tel: +49 / +89 / 36 40 72
Fax: +48 / +89 / 361 61 99




 
