Sparqlification mapping language

From Sparqlify Wiki
(Redirected from SML)
Jump to: navigation, search

The Sparqlification Mapping Language (SML) is a human readable syntax for the expression of RDB2RDF mappings. SML is also aimed at being suitable for SPARQL-to-SQL rewriting and for mapping CSV data.

Contents


Introduction

The Sparqlification Mapping Language (SML) is an RDB2RDF mapping language, designed to be expressive, human readable and easy to learn. SML provides means to describe "virtual RDF graphs" or "RDF views" over a relational database or CSV source. This definitions are then used e.g. by the Sparqlify tool to provide SPARQL access to the relational or CSV data, or to create RDF dumps.

The structure of such a mapping configuration, called view definition, is displayed in the graphic below and introduced in the following.

Graphic showing the parts and terminology of SML

Synopsis

 [(PREFIX prefix_name : IRI)[, ...]]
 CREATE VIEW name AS
   CONSTRUCT {
     quad-pattern
   }
   [ WITH
     variable-definitions
     [ CONSTRAIN constraints ]
     FROM
       sql-expr
   ]
     
 and variable-definitions is:
   a set of expressions of the form
      var = term-ctor-expr
 
 and term-ctor-expr is:
   { BNODE ( expr[, ...] ) |
     URI ( expr[, ...] ) |
     PLAINLITERAL(expr, expr) |
     TYPEDLITERAL(expr, expr)
   }
 
 and expr is:
   { var |
     STR( expr ) |
     CONCAT( expr [, expr] ) |
     URLENCODE( expr ) |
     iri-or-qualified-name |
     string
   }
 
 and sql-expr is:
   { [[ sql-query-string]] |
     sql-table-or-view-name
   }  
 
 and constraints is:
   { var PREFIX (namespace-ref, [...]) }
 
 and namespace-ref is:
   string[:]
 
 and iri-or-qualified-name is:
   { IRI | qualified-name }

Description

CREATE VIEW defines an RDF view on relational data. Conceptually, the RDF data is obtained row-wise as follows: For each row of the table specified in the FROM clause, first bind the variables of the WITH clause to the values obtained through evaluation of the term-ctor-exprs. Afterwards, instanciate the quads by replacing all variables with their corresponding values in order to obtain the RDF data. Note that 'static' quads, i.e. quads independent of an underlying table, can be defined by omitting the WITH clause (and thus also the FROM clause).

Parameters

name

The name of the view to be created.

quad-pattern

An RDF quad pattern specified using standard SPARQL syntax according to [1].

WITH variable-definitions

This clause specifies how the SPARQL variables of the CONSTRUCT clause are bound to RDF terms created from each row of the underlying table.

term-ctor-expr

A term constructor function with an input expression, yielding an RDF term when evaluated. A term constructor function can either be BNODE to create blank nodes, URI to create a URI resource, PLAINLITERAL to generate plain and TYPEDLITERAL to generate typed literals.

constraints

Constraint expressions that give hints for performance optimizations.

sql-expr

The definition of a logical table to apply the mapping to. This can be either the name of an existing relational table, the name of an SQL view or an arbitrary SQL expression. When defining the logical table via an SQL expression, this has to be put in double brackets, e.g. [[SELECT * FROM employee]]

var

A variable, syntactically based on the variable definition of the SPARQL 1.1 Query Language specification. A variable name in SML may further contain white space as well as additional characters, not allowed in the SPARQL specification, if it is enclosed in single or double quotes.

expr

An expression defining the input of a term constructor. Expressions can contain built-in functions to generate a string representations of a given input (STR), for string concatenation (CONCAT), or to apply URL encoding (URLENCODE). They can contain variables referring to column names of the underlying logical table defined in sql-expr, IRIs or its qualified names, as well as strings.


Example

An SML example mapping employees to RDF is given below.

Prefix ex: <http://ex.org/>.
Prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Prefix xsd: <http://www.w3.org/2001/XMLSchema#>
 
Create View employee As
    Construct {
        ?e  a ex:Employee;
            rdfs:label ?l ;
            ex:age ?a .
    }
    With
        ?e = uri(ex:employee, ?EMPNO)
        ?l = plainLiteral(?ENAME)
        ?a = typedLiteral(?AGE, xsd:int)
    From
        EMP


Notes for SML implementors

  • Typically, SML processors need to perform database schema dependent rewrites of SML view definitions in order to account for nullable columns.


There are currently projects for converting Sparqlify-ML to R2RML and vice versa.

Personal tools
Namespaces

Variants
Actions
Navigation
Documentation
In Use
Work in progress
Toolbox