How similar are Relational Database Languages and Logic Programming?

clojure, clojure-core.logic, prolog, relational-database

Solution

Similarities are captured by Datalog query language. Here is motivation and better explanation of connection between logic and databases. This excerpt should address your question:

Nevertheless, coupling Prolog and relational databases show some dissonances. Facts and rules in Prolog are organized in a total order and the semantics of a Prolog program depends on this order. In contrast, relations in a database are considered as unordered sets of tuples and the result of a query is independent from any physical order. The processing of Prolog programs is tuple oriented while relational databases are set oriented. Prolog offers procedural features like the cut predicate to allow the programmer to control the inference process. The order of evaluation of a Prolog program is pre-determined, whereas expressions in relational calculus are purely declarative and the actual evaluation is left to a query processor which may rearrange the query for optimization purposes. Optimization of queries was crucial for the success of relational databases. The procedural nature of the Prolog engine leaves the burden of optimization with the programmer.

Problem

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?

Original source

Related problems