I think a PrologForMassiveData as described below would be the language of choice for TopMind
(collected together from RelationalAlgebra, RelationalProgrammingLanguage and TableOrientedProgramming).
-- GunnarZarncke
'PrologLanguage is an in-memory database of "facts".'
- "In memory" That should be considered an implementation detail. Ideally, the distinction between RAM and disk should not be something a developer has to worry much about. -- top
- Sorry, this page was written too fast and late. It was a copy from somewhere else. It meant: Prolog is considered by some as an in-memory database of "facts". But if you extend it in the way proposed below to handle persistent data, then the distinction you mentioned should in fact become an implementation detail. --.gz
PrologLanguage has tuples, but you examine them using pattern matching instead of using labels. Prolog is based on predicate logic rather than relational calculus.
RelationalCalculus is, I think, a restricted form of predicate logic. The truth statements of prologs are similar to the rows of a relational table:
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. Or with actual SQL you might use views or 'cursors'. A rule in
PrologLanguage expresses this relationship much more succinctly.
In any case, can an SqlQuery? be mapped to a PrologRule??
Of course - see http://www.sikorskiy.net/prj/PrologSQL/index.html
A PrologForMassiveData could extend PrologLanguage with the following features:
- annotations for facts (the truth statements for rows above) and rules, that give hints to the compiler about size and atomicity or the 'relation'.
- special forms (predicates) for setting up the PrologDb?.
- variants of assert() and retract, that work persistently on the PrologDb?.
- SyntacticSugar: inline SQL syntax for rules.
A variant of this approach has been taken for
HaskellLanguage. See
HaskellDb.
See RelationalLanguage, RelationalAlgebra, RelationalProgrammingLanguage and TableOrientedProgramming
SetOrientedProgramming, PrologLanguage