A tool for translating R2RML mappings and relational data (databases) into Datalog programs and fact files in Soufflé syntax.
Powered by RMLMapper for parsing mappings and data.
- Input: R2RML mappings and relational databases
- Output: Datalog programs and fact files (Soufflé syntax)
- Easy to use: Simple command-line interface
- Integration: Leverages RMLMapper for robust mapping support
- Requirements
- Installation
- Usage
- Example
- Command-Line Options
- Running the Datalog Programs
- Troubleshooting
- Support & Contact
- License
- References
- Java 8+
- Access to your relational database
- R2RML mapping file(s)
-
Download the JAR
Download the latest release of
parser.jarfrom the releases page or build it yourself. -
Verify Java
Make sure Java is installed:
java -version
java -jar parser.jar -m <mappings.ttl> -dsn <jdbc:driver://...> -u <dbuser> -p <dbpass> -o <output_dir>Parameters:
-m: Path to R2RML mappings file-dsn: Database connection string JDBC format-u: Database username-p: Database password-o: (Optional) Output file path
To see all available options:
java -jar parser.jar -hTranslate R2RML with MySQL:
Consider a relational database with a table Student that has the following data:
| Name |
|---|
| Venus |
The following R2RML mapping file mapping.ttl defines how rows from the Student table are mapped to RDF triples.
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.com/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@base <http://example.com/base/> .
<TriplesMap1>
a rr:TriplesMap ;
rr:logicalTable [
rr:tableName "Student" ] ;
rr:subjectMap [
rr:template "http://example.com/{Name}" ] ;
rr:predicateObjectMap [
rr:predicateMap [ rr:constant foaf:name ] ;
rr:objectMap [ rr:column "Name" ] ] .Running the R2RML2Datalog Translator on this mapping file and the relational data can be done with the following command:
java -jar parser.jar -m mapping.ttl -dsn jdbc:mysql://localhost:3306/mydb -u user -p pass -o outputPath/output.rlsThe result is the following Datalog program and fact files:
Generated Soufflé Datalog Program
.functor toIRI(x:symbol):symbol
.decl lt0(x0:symbol)
.input lt0
.decl eval_7227202602e14113a2d06e0ac084adcd2_lt0(x0:symbol, y:symbol)
.decl eval_7227202602e14113a2d06e0ac084adcd4_lt0(x0:symbol, y:symbol)
.decl eval_7227202602e14113a2d06e0ac084adcd5_lt0(x0:symbol, y:symbol)
.decl Subject0_lt0(x0:symbol, y:symbol)
.decl Predicate00_lt0(x0:symbol, y:symbol)
.decl Object00_lt0(x0:symbol, y:symbol)
.decl triple(s:symbol, p:symbol, o:symbol)
.decl quadruple(s:symbol, p:symbol, o:symbol, g:symbol)
eval_7227202602e14113a2d06e0ac084adcd2_lt0(cat("http://example.com/", @toIRI(x0)), x0) :- lt0(x0).
eval_7227202602e14113a2d06e0ac084adcd4_lt0("http://xmlns.com/foaf/0.1/name", x0) :- lt0(x0).
eval_7227202602e14113a2d06e0ac084adcd5_lt0(x0, x0) :- lt0(x0).
Subject0_lt0(cat("<", cat(s, ">")), x0) :- eval_7227202602e14113a2d06e0ac084adcd2_lt0(s, x0).
Predicate00_lt0(cat("<", cat(p, ">")), x0) :- eval_7227202602e14113a2d06e0ac084adcd4_lt0(p, x0).
Object00_lt0(cat("\"", cat(o, "\"")), x0) :- eval_7227202602e14113a2d06e0ac084adcd5_lt0(o, x0).
triple(s, p, o) :- Subject0_lt0(s, x0), Predicate00_lt0(p, x0), Object00_lt0(o, x0).
.output triple
.output quadruple
fact file (lt0.facts)
Venus
Additional Examples
For more examples, please refer to the R2RML2Datalog-Tests repository, where we run our prototype on the official R2RML test cases.
This repository also includes the necessary user-defined C++ functions required by Soufflé to evaluate the generated Datalog programs and facts. These functions are implemented in the file functors.cpp.
To execute the Datalog programs:
-
Build Soufflé
Follow the official build instructions provided here:
👉 https://souffle-lang.github.io/build -
Integrate Custom Functors
Add thefunctors.cppfile to the Soufflé source directory and follow the integration commands here:
👉 https://souffle-lang.github.io/functors -
Execute the Datalog Program
Run Soufflé on the Datalog program and facts files following the simple execution steps here:
👉 https://souffle-lang.github.io/simple
Please follow https://souffle-lang.github.io/execute for more execution options
Example
Running the Soufflé Datalog reasoner on the generated Datalog program and fact file from our Example results in two csv files containing the output RDF triples and quadruples. For our example, the output is a single triple:
<http://example.com/Venus> <http://xmlns.com/foaf/0.1/name> "Venus" .
- Ensure you have Java 8 or higher installed and accessible in your environment.
- For database connections, please make sure the JDBC driver is available and the connection parameters are correct.
For any issues, please contact:
- Ali Elhalwati: ali.elhalawati@kuleuven.be
- Anastasia Dimou: anastasia.dimou@kuleuven.be
This project is licensed under the MIT License.
-
R2RML: RDB to RDF Mapping Language
Souripriya Das, Seema Sundara, Richard Cyganiak.
World Wide Web Consortium (W3C), Working Group Recommendation, 2012.
http://www.w3.org/TR/r2rml/ -
Automated metadata generation for Linked Data generation and publishing workflows
Anastasia Dimou, Tom De Nies, Ruben Verborgh, Erik Mannens, Peter Mechant, Rik Van de Walle.
Proceedings of the 9th Workshop on Linked Data on the Web*, Montreal, Canada, 2016.
Paper -
Soufflé: On Synthesis of Program Analyzers
Herbert Jordan, Bernhard Scholz, Pavle Subotić.
In Proceedings of the Computer Aided Verification (CAV), 2016.
https://souffle-lang.github.io/index.html -
A Declarative Formalization of R2RML Using Datalog and Its Efficient Execution Ali Elhalawati, Anastasia Dimou, and Jan Van den Bussche. In RuleChallenge@RuleML+RR, 2025. Paper