prolog to SQL converter

It makes more sense to do an sql query from prolog, which can then be translated into prolog facts. e.g. Prolog ODBC Library

This removes all restrictions and keeps the two languages separated into their proper places.


Recommending:

https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/prolog/code/io/pl2sql/0.html

my advice- use Eclipse prolog (http://www.eclipseclp.org/) (not (here) to be confused with prolog in the eclipse IDE).

I spent hours trying to get the code to compile in 4 other prologs(!) and 4 minutes to compile in eclipse.

When it works, it's a thing of beauty.

Credit to Herr Draxler of course


The mapping isn't very good. SQL, for example, doesn't do backtracking, unification, lists, or adhoc nested structures.

Prolog doesn't deal well with composite objects, indexes, etc.

I'd say it's a no-go.


Yes, of course.

A premise for skeptics: any semi-decent book on database theory mentions Datalog (which is Prolog-like) and theorems which demonstrate that is possible to translate it to/from Relational Algebra (RA) (under specific restrictions).

SQL is not faithful to RA or relational calculi, but is enough to support Prolog:

  • Christoph Draxler has developed a Prolog to SQL compiler (PL2SQL) for his thesis, available for download (.tgz) - also here at CMU Artificial Intelligence Repository (it was adapted and included in at least: Ciao Prolog and SWI-Prolog via Blipkit - Biomedical LogIc Programming Knowledge Integration Kit);
  • Igor Wojnicki has developed for his PhD (A Rule-based Inference Engine Extending Knowledge Processing Capabilities of Relational Database Management Systems) a prototype system implementing his Jelly View technology called ReDaReS, but it seems not available for download;
  • Relational Abstract Machine (RAM) translates Prolog to Relational Algebra, but it doesn't seems to have a SQL backend;
  • Walter D. Potter has a couple of papers on Prolog/RDBMS integration;
  • Kevin Boone's paper on Using SQL with Prolog to improve performance with large databases is also interesting;
  • and so on...

Tags:

Sql

Prolog