XSPARQL RDB2RDF

This page describes the implementation of the RDB2RDF Direct Mapping and R2RML mapping language in XSPARQL. Currently XSPARQL can access PostgreSQL and MySQL databases.

Configuring the database connection

There are two different ways to configure the database connection.

  1. via command line arguments by specifying the following parameters:
    --mysql Connect to a MySQL database
    --psql Connect to a PostgreSQL database
    --dbName Name of database to connect to
    --dbPass Prompt for user password
    --dbUser Username for database connection
  2. using a configuration file and specifying it as the parameter of the --dbConfig command line parameter. The configuration file should have the following structure:
    dbDriver=(mysql | psql)
    dbName=db
    dbUser=user
    dbPasswd=passwd

Database configuration options

In order to use XSPARQL with MySQL, the following options need to be included in the 'my.ini' configuration file:
sql-mode="PIPES_AS_CONCAT,ANSI_QUOTES" and also the "default-storage_engine" should be set to "innodb".

In order to handle international characters (such as this RDB2RDF testcase), java must be used with the command line option:
-Dfile.encoding=UTF-8

Executing R2RML mappings in XSPARQL

In order to execute your mappings you should run:

java -jar cli-VERSION-jar-with-dependencies.jar -r2rml "mapping_file" <database settings>

where 'VERSION' is the XSPARQL's downloaded version number.

Executing the Direct Mapping in XSPARQL

In order to execute your mappings you should run:

java -jar cli-VERSION-jar-with-dependencies.jar -dm "base uri" <database settings>

where 'VERSION' is the XSPARQL's downloaded version number.

Syntax Overview

The following XSPARQL query returns the 'name' attribute of the 'Student' relation:
for name as $name from Student
return $name

The next query creates some RDF data from the same relation:
prefix foaf: <http://xmlns.com/foaf/0.1/>
for name as $name from Student
construct { [ foaf:name $name ] }