Relational Programming Language

A relational programming language (RPL) is a DeclarativeLanguage built around the RelationalModel of data. StructuredQueryLanguage (SQL) is an example.

A relation can be viewed as a reversible function that can return an arbitrary number of values. For example, the "square root" relation maps the number [0] to itself, but maps [4] to [2 -2]. Relations can also be arranged as tables, and can be self-describing. For these reasons, relational programming can be seen as a generalization of functional programming.

The internet archive has a fascinating set of papers from the 1980's by Bruce J MacLennan? at the Naval Postgraduate school in Monterey:

MacLennan?'s approach combines the relational calculus with ideas from the FP language by JohnBackus and a syntax inspired by the constructed language Loglan (from which LojbanLanguage is derived). The resulting notation is somewhat reminiscent of JayLanguage or AplLanguage.

And here I was thinking about stored procedure / trigger languages that execute "in" a RelationalDatabase: To me, these seem more like imperative languages that happen to allow SQL and DDL statements -- what would PL/SQL look like, for instance, if it was "truly relational" (whatever that means)?

See also Jay Earley's VERS 2, a ProceduralProgrammingLanguage? built around the RelationalModel of data. For example, this paper:

Jay Earley
"Relational Level Data Structures for Programming Languages". Acta Informatica 2: 293-309 (1973)

Also LIBRA - A general-purpose programming language based on the algebra of binary relations
"Ordinary programming languages calculate functions. Sometimes a function is inappropriate. For example, 4 has two square roots, +2 and -2, but an ordinary programming language provides a sqrt function that returns only one of the roots."

The PrologLanguage could be considered a relational programming language.

Not really. PrologLanguage has no inherent support for labeled tuples. All it has is untyped lists of "atoms". In this respect it is quite similar to LispLanguage. I suppose you could add support for labeled (typed) tuples, though. OTOH one of the fundaments of PrologLanguage is an in-memory database of "facts" (forgot the actual term - clauses maybe? - but "facts" describes them better than original).

PrologLanguage has tuples, but you examine them using pattern matching instead of using labels. Prolog is based on predicate logic rather than relational calculus. Relational calculus is I think a restricted form of predicate logic.

The truth statements of prologs are similar to the rows of a relational table. (are there your tuples above?)

 employee ('Joe Doe', 1979, 'Department of Defense').
 employee_managed_by ('Joe Doe', 'Mister X').

The thing that RelationalCalculus is missing are the rules of Prolog. It is straightforward to have a "directReports" relationship in a relational table--associating each employee with his/her boss--but deriving the "indirectReports" relationship (the transitive closure of the directReports relationship) is trickier. You can do it with RelationalJoin?s, but that's ugly. A rule in PrologLanguage expresses this relationship much more succinctly.

This can be made into a PrologForMassiveData.

Also see TutorialDee, RelationalLanguage, PrologForMassiveData, EmbraceSql

View edit of May 12, 2014 or FindPage with title or text search