Database Reference
In-Depth Information
We denote this cube as
ex:HouseholdSlice
. We can see that the resulting cube
has only the
Time
dimension (level
ex:Year
)andthe
ex:Household
measure.
The SPARQL query that implements the slice operation is shown next:
CONSTRUCT
{
?id a qb:Observation ; qb:dataSet ex:dataset-hh2 ; ex:Year ?year ;
ex:Household ?sumHhold .
}
WHERE
{{
SELECT ?year (SUM(?hhold) AS ?sumHhold)
(iri(concat(
''
http://example.org/hhold#SliceGeo
''
,
strafter(?year,
''
http://example.org/hhold#
''
))) AS ?id)
WHERE
{
?o qb:dataSet ex:dataset-hh ; ex:Year ?year ;
ex:UnitaryAuthority ?ua ; ex:Household ?hhold .
?ua: qb4o:inLevel ex:UnitaryAuthority ; skos:broader ?gor .
?gor: qb4o:inLevel ex:GovernmentO
ceRegion ;
skos:broader ?country .
?country: qb4o:inLevel ex:Country ; rdfs:label ?countryLabel .
FILTER(?countryLabel =
''
England
''
@en)
}
}}
Since observations are at the granularity of unitary authority, in the subquery
we must roll up to the country level. Then, the
FILTER
condition implements
thes iceoperation.The
SELECT
clause of the subquery aggregates all
observations pertaining to England at the year level. As in the previous query,
the IRIs of the new query are generated in the
SELECT
clause of the subquery.
Finally, consider the following dice operation:
DICE(HouseholdCS, Time.Year
>
2007),
which obtains a subcube from the
HouseholdCS
data cube containing only
data from 2007 onward. This is implemented by the following query:
CONSTRUCT
GROUP BY ?year
{
?id a qb:Observation ; qb:dataSet ex:dataset-hh ;
ex:Year ?year ; ex:UnitaryAuthority ?ua ; ex:Household ?hhold .
}
WHERE
{{
SELECT ?ua ?year ?hhold
(iri(concat(
''
http://example.org/hhold#Dice
''
,
strafter(?ua,
''
http://example.org/hhold#
''
),
'' ''
,
strafter(?year,
''
http://example.org/hhold#
''
))) AS ?id)
WHERE
{
?o qb:dataSet ex:dataset-hh ; ex:Year ?year ;
ex:Household ?hhold ; ex:UnitaryAuthority ?ua .
FILTER (?year
>
= 2007)
}}}
As shown above, the dice condition is implemented by the
FILTER
clause.
Note that the output schema is identical to the cube schema.
14.4 Representation of the Northwind Cube
in QB4OLAP
In this section, we show how the Northwind data cube can be represented in
RDF using the QB4OLAP vocabulary. The Northwind data cube has been
introduced in Fig.
4.2
. We show it again in Fig.
14.8
to ease readability.
Search WWH ::
Custom Search