# Re: SPARQL query result representation in Algebra

• From: Jeen Broekstra <jeen.broekstra@gmail.com>
• Date: Tue, 03 May 2011 13:58:55 +1200
• Message-ID: <4DBF615F.8060302@gmail.com>
```On 3/05/2011 07:43, Jitao Yang wrote:

> Do you know how to represent the SPARQL query result in Algebra?

Well, the point of any algebra is really to have a formal arithmetical
expression that can be evaluated using rules of operation. In that
sense, expressing a _result_ in an algebra is pointless, since the
result is the outcome of the evaluation, not something that can be
evaluated. The result is simply some collection of the terms that the
algebra operates on.

Having said all that: the result of a SPARQL query is known as a
solution sequence, which is formally defined as a (possibly unordered)
list of solution mappings. Each solution mapping is a partial function
from variables to RDF terms. A solution mapping can be written as m(?V
-> t), mapping variable V to term t: { (V,t) }

So assuming we have the following query result:

?x	?y
=============
ex:a	ex:b
ex:c	ex:d

You could conceivably represent it in 'algebraic form' as follows:

[m_1(?x -> ex:a), m_1(?y -> ex:b), m_2(?x -> ex:c), m_2(?y -> ex:d)]

or more concisely, as :

[ {(x, ex:a), (y, ex:b)}, {(x, ex:c), (y, ex:d)} ]

Does that help?

Regards,

Jeen
```

Received on Tuesday, 3 May 2011 01:59:29 UTC