What are the similarities and differences in terms of the fundamental concepts and implementation between a relational database language sql
and a logic programming language such as prolog
and clojure's core.logic
? Are the two interchangeable?
Although SQL and Prolog both demonstrate first-order logic concepts, neither is a complete implementation of the predicate calculus.
Prolog and other logic programming languages are heavily dependent on recursion, both for definition of data structures as well as for predicates.
SQL per se does not allow recursion, and the introduction of stored procedures has been done with limitations on the depth of nesting of such calls. Eg. SQL Server 2000 thru 2012 allow at most 32 nested calls.
In relational databases the "relations" are reified as tables (or more flexibly, as views). The most similar aspect of Prolog is dynamic factbases, which in some implementations (SWI, Amzi) allow indexing for performance, very similar to indexing of relational tables for performance in SQL.
Although SQL RDBMS are designed to efficiently work with much large sets of data than a Prolog implementation typically needs, Prolog can at least be used to prototype both the database and process aspects of a system design.
See here for a 2005 thesis that explores extending relational databases with Prolog inference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With