<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>OBDA for Temporal Querying and Streams</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Christian Neuenstadt</string-name>
          <email>neuenstadt@ifis.uni-luebeck.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ralf Möller</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Özgür L. Özçep</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute of Information Systems (Ifis) University of Lübeck Lübeck</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Data changes worldwide in size and over time and when new data arrives rapidly from different sources, an easy access to dynamic data becomes a keyfactor. Therefore, temporalizing and streamifying ontology-based data access (OBDA) is a very important topic today, where the industry still relies on algebraic queries. We contribute to the practical efforts in this field by showing how a specific ontology-based stream querying language can be transformed with respect to mappings into standard SQL queries. For that purpose we choose the stream and temporal reasoning query language STARQL. STARQL is motivated by industrial usecases and evaluated in the European research project Optique. It offers access to temporal and streaming data as well for reactive diagnosis or continous monitoring.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        The following work contributes to research in the field of OBDA1 on
temporal data [
        <xref ref-type="bibr" rid="ref3 ref4">4,3</xref>
        ] and especially on streaming data. We show how we transform
an ontology based stream data query language into equivalent relational
algebra queries in SQL for timetagged data tables. Our approach extends previous
work[
        <xref ref-type="bibr" rid="ref10 ref11 ref8 ref9">9,11,10,8</xref>
        ] and can be applied to the paradigm of streaming data as well as
temporal data itself.
      </p>
      <p>
        Sensor data is playing an important role in the IP7 EU project Optique.
Siemens, one of the industrial stakeholders, provides huge amounts of sensor
data to the project [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Thus, in this project the idea of processing streams with
a sliding window (e.g. in [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]) has been extended by defining a finite sequence
of consistent ABoxes for each window, which represent a sequence of time and
extends previous ideas of adopting OBDA to streams [
        <xref ref-type="bibr" rid="ref12 ref5 ref6">6,5,12</xref>
        ], where the window
content was treated as a single ABox. The idea of a sliding window is used for
reactive diagnostics on temporal sensor data and accessed by within the project.
In addition, a query language for streams has been developed, which is called
STARQL2. STARQL is a SPARQL-like query languange with added window
definition and a special clause for additional time constraints and querying a
sequence of ABoxes. It has been designed for advanced data access to work
equally for stream and temporal reasoning.
      </p>
      <p>The idea of an ABox sequencing strategy makes the required steps, rewriting
and unfolding for Ontology Based Data Access a challenging task. In the next
section, we analyze the rules for STARQL transformations into algebraic queries
like SQL and show that the rewriting and unfolding steps are indeed possible.
2</p>
      <p>Transformation Rules for Streaming Data with
STARQL
As mentioned in the last section, rewriting and unfolding of the ABox sequencing
strategy is the most challenging task. STARQL uses a clause especially designed
for temporal data access called Having Clause. We will concentrate explicitly on
transforming the STARQL Having-Clause into an algebraic query language in
this paper. An example for the use of a Having Clause can be seen in Listing
1. Here we see the definition of a stream Sout (Line 1), its output is defined
as sensors of the type MonInc, which stands for monotonically increasing (Line
2). In line three the input stream with sensor values and the sliding window
operator is defined, which is of size three seconds and slides with exactly one
second for each window evaluation. In the next part the sequence of ABoxes
for each window is defined. StdSeq stands for a sequence where each data set,
which is represented by another timestamp, is placed in different ABoxes by an
increasing order. The important part to evaluate the content of each window is
shown in lines 5 to 7. For STARQL a new so called Having Clause has been
explored. Its syntax is defined in first order logic using quantors for binding
variables, conjunctions, disjunctions or negations of atoms, which can be graph
triples or logical and arithmetic expressions. In our specific example a filter for
monotonically increasing sensor data is used. It can be read as follows: for all
timepoints i smaller than j it is true that if in i a sensor has a value x and in j
the same sensor has a value y, then x must be smaller than or equal i.</p>
      <p>
        An expression of the Having Clause from Listing 1 in first order logic is shown
in formula 1. For an analysis of the STARQL syntax and semantics we refer to
[
        <xref ref-type="bibr" rid="ref10 ref9">9,10</xref>
        ].
      </p>
      <p>8i; j; x; y((R(i; s; x) ^ S(j; s; y) ^ i &lt; j) ! (x
y))
(1)</p>
      <p>We will take this query as a running example in the further paper.
1 CREATE STREAM S_out AS
2 CONSTRUCT GRAPH NOW { ?s rdf : type MonInc }
3 FROM STREAM S_Msmt [NOW -2s , NOW ] - &gt;"1S "^^ xsd : duration
4 SEQUENCE BY StdSeq AS seq
5 HAVING FORALL ?i ,? j IN seq ,?x ,? y:
6 IF ( GRAPH ?i { ?s : val ?x } AND GRAPH ?j { ?s : val ?y } AND ?i &lt; ?j)
7 THEN ?x &lt;= ?y</p>
      <p>Listing 1: Example query in STARQL</p>
      <p>
        Classical OBDA without querying time or time sequences has been researched
for many years. In the non-temporal case the query language SPARQL is
commonly used. Query languages like SPARQL (or in our temporal case STARQL)
that are transformed to relational algebra must be domain independent, which
can be achieved by a syntactical criterion requiring that all variables have to be
range restricted (see [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] for a definition of domain independence). An example
for a non restricted variable would be in the STARQL case a Having Clause
of “?y &gt; 1” . In this case, the variable ?y could be evaluated to numbers
between one and infinity. We can range restrict the variable ?y by another atom
like “ ?y &gt; 1 AND GRAPH i { ?sens :hasVal ?y }”. Here the variable ?y is not
range restricted for the atom “ ?y &gt; 1”, but for the complete clause, because it is
restricted to the concrete elements that actually exist in ABox i or if we stick to
the example, all values that have been measured by a sensor. Thus, we see the
Having Clause can be range restricted, although parts of it are not restricted
itself. STARQL requires the Having Clause to be range restricted over all, which
is guaranteed by its formulation rules. Thus, we can assume that the Having
Clause is domain independent for our cases and can be indeed transformed into
relational algebra. For reasons of space restriction, we refer for more specific
information on STARQL domain independence to [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>For our transformation of the STARQL Having Clause, we make two more
assumptions. First, our database offers a view that represents time tagged data
with a time sequence representation of the sliding window in two additional
columns, where the schema consists of WindowID, ABoxID, Timestamp and
[Datacolumns] for every temporal table. An example view for a sliding window
with measured data is shown in Table 1. It includes measurements for a single
sensor and describes two windows with WindowID 1 and 2, where the window
width is of three minutes. Every single ABox in the sequence can be accessed by
the ABoxID in the second column.</p>
      <p>For the second assumption we assume additionally that the unfolding for a
single graph triple “GRAPH i { subject predicate value}”, where i respresents
the index variable of ABoxes, is trivial and can be unfolded with mappings to
aid!i wid;aid;x1;:::;xn (R), where wid represents the evaluated window, aid the
ABox, x1; :::; xn the specific data columns and R the described data view in
sliding window format. A projection of the WindowID is necessary for temporal
queries, where we explore several time windows in parallel. For streaming queries,
where we evaluate the data of a single window per timepoint only, an index
variable for comparing the ABoxes in a sequence would be enough.</p>
      <p>
        Making these assumptions, the Having Clause of STARQL can be
transformed by following the algorithm below for transforming from Safe Range
Normal Form into Relational Algebra Normal Form (for detailed informations and
proofs, see [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]).
      </p>
      <p>First, we normalize the Safe Range Form of the Having Clause by five steps:
1. Variable substitution: All variable names are substituted until every
variable is bound only once and no variable occurs free and bound.
2. Remove universal quantifier: We replace all 8x by :9x:
3. Remove implications: We replace all ! by : _
4. Push negations: We push every negation down into the formula until every
child of a negation is either an atom or an exists quantifier
5. Flattening: Flatten every and, which is the child of an and, do the same
for or and exists quantifiers</p>
      <p>Second, we normalize again for the relational algebraic normal form by three
additional steps:
1. Push into or: We push every or upwards until there is no or as a child of
an and.
2. Push into quantifier: if is of the form 1 ^ ::: ^ n ^ 9x and not all free
variables of are range restricted, push a subset of 1 ^ ::: ^ n as conjunct
into until all free variables of are range restricted.
3. Push into negated quantifier: if is of the form 1 ^ ::: ^ n ^ :9x and
not all free variables of are range restricted, copy a subset of 1 ^ ::: ^ n
as conjunct into until all free variables of are range restricted.
:9i; j; x; y(R(i; s; x) ^ S(j; s; y) ^ i &lt; j ^ x &gt; y)
(2)</p>
      <p>After both normalization steps the Having Clause example from Listing 1
can now be written in RANF as shown in Formula 2.</p>
      <p>
        For transforming a formula from Relational Algebraic Normal Form (RANF)
into an algebraic query E , we adopt the modified algorithm 1 with added
window and ABox information from [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ].
      </p>
      <p>Unfolding of the RANF formula yields to the algebraic query in Formula 3.
fhig –
wid;aid;s( x&gt;y( i&lt;j ( wid;aid;s;x(R) 1
wid;aid;s;y(S))))
(3)</p>
      <p>In the next step, we replace the left part of the subtraction with the projection
of the right side without making use of any specific selection.</p>
      <p>wid;aid;s( wid;aid;s;x(R) 1
–
wid;aid;s( x&gt;y( i&lt;j ( wid;aid;s;x(R) 1</p>
      <p>wid;aid;s;y(S))
wid;aid;s;y(S))))
(4)
Algorithm 1 (Translation from RANF to Algebra)
Input: a formula in modified RANF
Output: an algebra query E equivalent to
x = a
R(e) !</p>
      <p>! fhx : aig
^ ! if is x = x, then E</p>
      <p>f ( wid;aid;x1;:::;xn ( F (R)))
if is x = y, (with x, y distinct) then
x=y(E ), if fx; yg</p>
      <p>f ree( )
x=y(E
x=y(E
1 x!yE ), if x 2 f ree( ) and y 2= f ree( )
1 y!xE ), if y 2 f ree( ) and x 2= f ree( )
= : 0, then
if is x 6= y, then x6=y(E )
if</p>
      <p>E – (E</p>
      <p>1 E 0 ), if f ree( 0)
E – E 0 , if f ree( 0) = f ree( )</p>
      <p>f ree( )
otherwise, E</p>
      <p>1 E
does not have “and” as parent)
:
1 _ ::: _ n
9x1,...,xn (x1,...,xn, y1,...,ym)
! fhig – E (if :
! E [ ::: [ E
!</p>
      <p>wid;aid;y1 ;:::;yn (E )</p>
      <p>Finally, we arrive at an algebraic query transformed from the STARQL
Having Clause in formula 4, which can now directly be written in SQL.</p>
      <p>This algorithm has been implemented in the stream query answering
prototype of the EU Optique project. A detailed description and evaluation of several
examples will be presented in future work.
3</p>
    </sec>
    <sec id="sec-2">
      <title>Conclusion</title>
      <p>In this paper we have shown how we transform the Having Clause of the stream
and temporal query language STARQL in general and described a specific
example. The transformation is done by three steps. First, we guarantee the domain
independence of STARQL by the Safe Range Normal Form. Second, we build
the Relational Algebraic Normal Form and third, we transform the formula into
an algebraic query. This algorithm has been implemented in the EU project
Optique and will be evaluated and optimized in future work.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Abiteboul</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hull</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vianu</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          : Foundations of Databases. Addison-Wesley (
          <year>1995</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Arasu</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Babu</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Widom</surname>
            ,
            <given-names>J.:</given-names>
          </string-name>
          <article-title>The CQL continuous query language: semantic foundations and query execution</article-title>
          .
          <source>The VLDB Journal 15</source>
          ,
          <fpage>121</fpage>
          -
          <lpage>142</lpage>
          (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Artale</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kontchakov</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wolter</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zakharyaschev</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Temporal description logic for ontology-based data access</article-title>
          .
          <source>In: Proceedings of the Twenty-Third International Joint Conference on Artificial Intelligence</source>
          . pp.
          <fpage>711</fpage>
          -
          <lpage>717</lpage>
          . IJCAI'
          <volume>13</volume>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Borgwardt</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          , Lippmann,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Thost</surname>
          </string-name>
          ,
          <string-name>
            <surname>V.</surname>
          </string-name>
          :
          <article-title>Temporal query answering in the description logic DL-Lite</article-title>
          . In: Fontaine,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Ringeissen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            ,
            <surname>Schmidt</surname>
          </string-name>
          ,
          <string-name>
            <surname>R.A</surname>
          </string-name>
          . (eds.)
          <source>Frontiers of Combining Systems. LNCS</source>
          , vol.
          <volume>8152</volume>
          , pp.
          <fpage>165</fpage>
          -
          <lpage>180</lpage>
          . Springer (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Calbimonte</surname>
            ,
            <given-names>J.P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jeung</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Corcho</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Aberer</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          :
          <article-title>Enabling query technologies for the semantic sensor web</article-title>
          .
          <source>Int. J. Semant. Web Inf. Syst</source>
          .
          <volume>8</volume>
          (
          <issue>1</issue>
          ),
          <fpage>43</fpage>
          -
          <lpage>63</lpage>
          (
          <year>Jan 2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>Della</given-names>
            <surname>Valle</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            ,
            <surname>Ceri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            ,
            <surname>Barbieri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            ,
            <surname>Braga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            ,
            <surname>Campi</surname>
          </string-name>
          ,
          <string-name>
            <surname>A.</surname>
          </string-name>
          :
          <article-title>A first step towards stream reasoning</article-title>
          . In: Domingue,
          <string-name>
            <given-names>J.</given-names>
            ,
            <surname>Fensel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            ,
            <surname>Traverso</surname>
          </string-name>
          , P. (eds.) Future Internet - FIS
          <year>2008</year>
          ,
          <article-title>LNCS</article-title>
          , vol.
          <volume>5468</volume>
          , pp.
          <fpage>72</fpage>
          -
          <lpage>81</lpage>
          . Springer Berlin / Heidelberg (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Kharlamov</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Solomakhina</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Özcep</surname>
            ,
            <given-names>Ö.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zheleznyakov</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hubauer</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lamparter</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Roshchin</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Soylu</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>How semantic technologies can enhance data access at siemens energy</article-title>
          .
          <source>In: Proceedings of the 13th International Semantic Web Conference (ISWC</source>
          <year>2014</year>
          )
          <article-title>(</article-title>
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Özçep</surname>
          </string-name>
          , Ö. L..,
          <string-name>
            <surname>Möller</surname>
          </string-name>
          , R.:
          <article-title>Ontology based data access on temporal and streaming data</article-title>
          . In: Koubarakis,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Stamou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            ,
            <surname>Stoilos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            ,
            <surname>Horrocks</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I.</given-names>
            ,
            <surname>Kolaitis</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Lausen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            ,
            <surname>Weikum</surname>
          </string-name>
          ,
          <string-name>
            <surname>G</surname>
          </string-name>
          . (eds.)
          <source>Reasoning Web. Reasoning and the Web in the Big Data Era. Lecture Notes in Computer Science</source>
          , vol.
          <volume>8714</volume>
          . (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Özçep</surname>
            ,
            <given-names>Ö.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Möller</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Neuenstadt</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zheleznyakov</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kharlamov</surname>
          </string-name>
          , E.:
          <article-title>Deliverable D5.1 - A semantics for temporal and stream-based query answering in an OBDA context</article-title>
          .
          <source>Deliverable FP7-318338</source>
          , EU (
          <year>October 2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Özçep</surname>
            ,
            <given-names>Özgür.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Möller</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Neuenstadt</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>A stream-temporal query language for ontology based data access</article-title>
          .
          <source>In: KI 2014. LNCS</source>
          , vol.
          <volume>8736</volume>
          , pp.
          <fpage>183</fpage>
          -
          <lpage>194</lpage>
          . Springer International Publishing Switzerland (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Özgür L. Özçep</surname>
            , Möller,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Neuenstadt</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>A stream-temporal query language for ontology based data access</article-title>
          . In: Bienvenu,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Ortiz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            ,
            <surname>Rosati</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            ,
            <surname>Simkus</surname>
          </string-name>
          , M. (eds.)
          <source>Proceedings of the 7th International Workshop on Description Logics (DL-2014)</source>
          (
          <year>2014</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Phuoc</surname>
            ,
            <given-names>D.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dao-Tran</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parreira</surname>
            ,
            <given-names>J.X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hauswirth</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>A native and adaptive approach for unified processing of linked streams and linked data</article-title>
          .
          <source>In: International Semantic Web Conference (1)</source>
          . pp.
          <fpage>370</fpage>
          -
          <lpage>388</lpage>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>