Database Reference
In-Depth Information
Next, we use the
Product
dimension to illustrate how to define dimensions.
The attributes of the levels are defined with the property
qb:AttributeProperty
as follows:
nw:ProductKey a qb:AttributeProperty ; rdfs:comment
''
Product Key
''
@en .
nw:ProductName a qb:AttributeProperty ; rdfs:comment
''
Product Name
''
@en .
nw:QuantityPerUnit a qb:AttributeProperty ; rdfs:comment
''
Quantity per Unit
''
@en .
nw:UnitPrice a qb:AttributeProperty ; rdfs:comment
''
Unit Price
''
@en .
nw:Discontinued a qb:AttributeProperty ; rdfs:comment
''
Discontinued
''
@en .
nw:CategoryName a qb:AttributeProperty ; rdfs:comment
''
Category Name
''
@en .
nw:Description a qb:AttributeProperty ; rdfs:comment
''
Description
''
@en .
A dimension is defined with the property
qb:DimensionProperty
. A dimension
level is defined with the property
qb4o:LevelProperty
, and the associated
dimension is defined with the property
qb4o:inDimension
. The property
qb4o:hasAttribute
is used to associate the attributes with a dimension level.
The definition of the
Product
dimension is shown next:
nw:ProductDim a rdf:Property, qb:DimensionProperty ;
rdfs:label
''
Product Dimension
''
@en ;
nw:Product a qb4o:LevelProperty ; qb4o:inDimension nw:ProductDim ;
qb4o:hasAttribute nw:ProductKey ; qb4o:hasAttribute nw:ProductName ;
qb4o:hasAttribute nw:QuantityPerUnit ; qb4o:hasAttribute nw:Discontinued ;
qb4o:parentLevel nw:Category .
nw:Category a qb4o:LevelProperty ; qb4o:inDimension nw:ProductDim ;
qb4o:hasAttribute nw:CategoryName ; qb4o:hasAttribute nw:Description .
The other dimensions and levels are defined analogously.
14.5 Querying the Northwind Cube in SPARQL
Given the schema of the Northwind cube in Fig.
14.8
expressed in QB4OLAP,
we revisit the queries of Sect.
4.4
in SPARQL.
Query 14.1.
Total sales amount per customer, year, and product category.
SELECT ?custName ?catName ?yearNo (SUM(?sales) AS ?totalSales)
WHERE
{
?o qb:dataSet nwi:dataset1 ; nw:Customer ?cust ;
nw:OrderDate ?odate ; nw:Product ?prod ; nw:SalesAmount ?sales .
?cust qb4o:inLevel nw:Customer ; nw:companyName ?custName .
?odate qb4o:inLevel nw:OrderDate ; skos:broader ?month .
?month qb4o:inLevel nw:Month ; skos:broader ?quarter .
?quarter qb4o:inLevel nw:Quarter ; skos:broader ?sem .
?sem qb4o:inLevel nw:Semester ; skos:broader ?year .
?year qb4o:inLevel nw:Year ; nw:year ?yearNo .
?prod qb4o:inLevel nw:Product ; skos:broader ?cat .
?cat qb4o:inLevel nw:Category ; nw:categoryName ?catName .
}
GROUP BY ?custName ?catName ?yearNo
ORDER BY ?custName ?catName ?yearNo
Search WWH ::
Custom Search