Database Reference
In-Depth Information
TABLE 5.1
SPARQL Algebra and Syntax
Algebra
Syntax
BGP
Set of triple patterns concatenated via.
Join
Concatenation of two groups {…} . {…}
Filter
FILTER
LeftJoin
OPTIONAL
Union
UNION
Graph
GRAPH
"literal"^^type ). If needed in arithmetic expressions, numeric literals (e.g.,
literals of type xsd:integer ) are parsed into the appropriate numeric
data type of Pig Latin at runtime. The RDF syntax does not define an internal struc-
ture of blank nodes, they just have to be distinguishable from URIs and literals.
Thus, we can also represent them as atoms with a leading underscore ( _ :nodeID ).
Hence, an RDF triple can be represented as a tuple with three fields of atomic type
( chararray ) with schema ( s:chararray, p:chararray, o:chararray ).
5.3.2 a lgebra t ranslation
For each operator of the SPARQL algebra we give a translation into a sequence
of Pig Latin commands illustrated by a representative example (P1-P6). First, we
introduce the needed terminology analogous to [12]: Let V be the infinite set of query
variables and T be the set of valid RDF terms (URIs, RDF literals, blank nodes).
Definition 5.1
A (solution) mapping μ is a partial function μ : V T . We call μ(? v ) the variable bind-
ing of μ for ? v . Abusing notation, for a triple pattern p we call μ( p ) the triple pattern that
is obtained by substituting the variables in p according to μ. The domain of μ, dom (μ),
is the subset of V where μ is defined and the domain of p , dom ( p ), is the subset of V
used in p . The result of a SPARQL query is a multiset of solution mappings Ω.
Definition 5.2
Two mappings μ 1 , μ 2 are compatible iff, for every variable ? v dom 1 ) ∩ dom 2 ), it
holds that μ 1 (? v ) = μ 2 (? v ). It follows that mappings with disjoint domains are always
compatible and the set-union (merge) of μ 1 and μ 2 , μ 1 ∪ μ 2 , is also a mapping.
Basic Graph Pattern (BGP). BGPs are the basis of all SPARQL queries as it is
the only operator that is evaluated directly on the underlying RDF data. The result
 
Search WWH ::




Custom Search