Databases Reference
In-Depth Information
Obviously, using the notation of rules, any BGP can be straightforwardly seen
as a conjunctive query (CQ) in the classical sense, and the more general concept
of a union of conjunctive queries (UCQs) can be defined as follows.
Definition 8 (Union of Conjunctive Queries (classical notion)).
A
con-
junctive query
(CQ) is a special rule of the form
q
(
x
)
←
Body
(
x,y
)
where x is a sequence of variables called
distinguished variables
, y is a sequence
of variables called
non-distinguished variables
,andBody
(
x,y
)
is a conjunction of
body atoms over these variables. A program P
q
(where we just write q when P is
implicit form the context) that consists of only rules with the same head q
(
x
)
(such
that q does not appear in any body) is a
union of conjunctive queries
(UCQ).
Given a (Linked) Dataset
Γ
and a SPARQL BGP query
Q
, the definition of
solutions from Definition 3 thus corresponds to the notion of entailed answers
for the corresponding classical conjunctive query
q
, written
Ans
(
q,
merge
(
Γ
))
(and used in the literature, cf. for instance [14]).
13
That is, in our context we can
equate
Ans
(
q,
merge
(
Γ
)) with the set of tuples
a
such that
q
(
a
)
∈
T
P
q
(
merge
(
Γ
)).
Note that as for SPARQL, all variables are considered to be distinguished, since
there is no “real” projection in the sense of classical conjunctive queries: any
BGP occurring inside a SPARQL query is evaluated as a conjunctive query
without non-distinguished variables, whereupon the SPARQL algebra evaluates
more complex patterns, such as
SELECT
clauses and so forth [30,21].
Example 2
The following SPARQL query asks for the labels and revenues (in EUR) of
organisations:
Query 1
SELECT ?X ?L ?R
WHERE { ?X a dbo:Organisation ; rdfs:label ?L ; dbo:revenueEUR ?R .}
This query asks to evaluating the basic graph pattern:
(?
X,
a
,
dbo:Organisation
)
,
(?
X,
rdfs:label
,
?
L
)
,
(?
X,
dbo:revenueEUR
,
?
R
)
}
{
which, respectively, in the classical notation corresponds to the following
conjunctive query:
q
(?
X,
?
L,
?
R
)
←
(?
X,
a
,
dbo:Organisation
)
,
(?
X,
rdfs:label
,
?
L
)
,
(?
X,
dbo:revenueEUR
,
?
R
)
.
13
We use merge(
Γ
) here synonymously with the knowledge base consisting of the facts
corresponding to the triples in merge(
Γ
).