Re: database: prolog and relational

From: Tony Douglas <tonyisyourpal_at_netscape.net>
Date: 4 Jun 2004 14:04:49 -0700
Message-ID: <bcb8c360.0406041304.112b229e_at_posting.google.com>


mAsterdam <mAsterdam_at_vrijdag.org> wrote in message news:<40bef1ee$0$15375$e4fe514c_at_news.xs4all.nl>...

Hi mAsterdam,

I haven't been following the thread too closely, but I could offer some comments which may (or probably may not) be helpful.

I have on occasion seen Prolog referred to as "relational". I think this is incorrect. A Prolog system effectively consists of a database of facts, a collection of predicates which tie the facts together (and can in turn assert new facts or retract old ones), a bactracking algorithm and a unifier. Although relational systems talk about internal and external predicates, and relations representing predicates, it's all too easy for that view to be lost in chatter about "tables", "fields" or even "files". In Prolog, it's made absolutely clear from the word go.

The Prolog facts database is not relational for (at least) a couple of reasons; mainly that the arguments of a fact are position dependent (ie. they aren't referred to by name), and the order of facts in a database affects the evaluation of predicates. (I don't have a Prolog interpreter in front of me just now; I'm pondering whether I can assert duplicate facts. I don't think there's anything to stop me but I've never intentionally done such a thing ;) ) There are no "columns" or "rows" per se. You can fake a lot of things up, and it's actually not too difficult to implement the relational operators in Prolog (I did it last year for various mad reasons).

Prolog's main difficulty is that the majority of implementations expect the database of facts to be memory resident when evaluating, rather than disk based. There have in the past been many and varied attempts at using Prolog as a front end to SQL databases; check through the DBLP bibliography at
http://www.informatik.uni-trier.de/~ley/db for info - check the SIGMOD papers for Prolog for hints. The book "Prolog and Databases" edited by Gray & Lucas (ISBN 0-7458-0371-7) looks interesting - might try finding that myself..! Alternatively,
http://dbpubs.stanford.edu:8090/pub/1995-14 is an interesting read. Doing a Yahoo on "prolog relational database" can throw up some good info as well.

Prolog is lots of fun, and can play some real games with what you think programming is (or should be) all about !

  • Tony
Received on Fri Jun 04 2004 - 23:04:49 CEST

Original text of this message