In this case, the rule is translated into a complex database query, which is then executed taking advantage of the query processing ability of the database system. All arguments are standard Prolog terms. It allows negation, the expression of arithmetic functions, and higher-order constructs such as grouping, sorting, and aggregate functions. Goal conjunctions translate to joins. Variables with single occurrences in the body are not translated.
Free variables translate to grouping attributes.
Shared variables in goals translate to equi-join conditions. Constants translate to equality comparisons of an attribute and the constant value. Nulls are translated to IS NULL conditions. In the following, we show the definition of a simple join view between the two database predicates emp and dept . NEW YORK Backtracking can then be used to retrieve the next row of the view.