Datalog is a logic programming language and a subset of the earlier Prolog1. The language is interesting as it can be used as a data query language akin to SQL with some important additional capabilities such as recursive queries. It is also expressive enough to allow for its use as an entailment mechanism for ontology languages such as the Web Ontology Language (OWL)2 and the Semantic Web.
The specific language that may be represented by the DATALOG-TEXT grammar includes typed attributes and functional dependencies for relations, negated and arithmetic literals, disjunction in rule heads, and constraint rules. With the exception of required support for typed attributes the other language features are opt-in using pragmas.
Datalog is a declarative logic programming language that is a syntactic subset of Prolog. While SQL is designed for querying and manipulating tabular databases, Datalog excels at querying graphs, performing deductive inference, and executing complex recursive algorithms.
A Datalog program consists of two main parts:
- EDB (Extensional Database): The raw data or "facts". Similar to rows in a SQL table.
- IDB (Intensional Database): The logical "rules". Similar to SQL Views, but they can be highly recursive and call each other dynamically.