Database Reference
In-Depth Information
The inner query computes the total sales amount for each customer and
order. Then, in the outer query, for each customer we select the maximum
sales amount among all its orders.
Subqueries are commonly used with the UNION and MINUS keywords.
The UNION combines graph patterns so that one of several alternative graph
patterns may match. For example, the query “Products that have been
ordered by customers from San Francisco or supplied by suppliers from San
Jose” can be written as follows:
SELECT DISTINCT ?prodName
WHERE
{{
SELECT ?prod
WHERE
{
?sales a ex:Sales ; ex:Sales#Product ?prod ;
ex:Sales#Customer ?cust .
?cust a ex:Customer ; ex:Customer#City ?custCity .
?custCity a ex:City ; ex:City#Name ?custCityName .
FILTER(?custCityName = '' San Francisco '' )
}}
UNION
{
SELECT ?prod
WHERE
{
?sales a ex:Sales ; ex:Sales#Product ?prod ;
ex:Sales#Supplier ?sup .
?sup a ex:Supplier ; ex:Supplier#City ?supCity .
?supCity a ex:City ; ex:City#Name ?supCityName .
FILTER(?supCityName = '' San Jose '' )
}}}
Analogously, the MINUS operation computes the difference between the
results of two subqueries. An example is the query: “Products that have not
been ordered by customers from San Francisco,” which can be written as
follows:
SELECT DISTINCT ?prod
WHERE { ?sales a ex:Sales ; ex:Sales#Product ?prod .
MINUS {{
SELECT ?prod
WHERE { ?sales a ex:Sales ; ex:Sales#Product ?prod ;
ex:Sales#Customer ?cust .
?cust a ex:Customer ; ex:Customer#City ?city .
?city a ex:City ; ex:City#Name ?cityName .
FILTER(?cityName = '' San Francisco '' ) }}}}
The inner query computes the products ordered by customers from San
Francisco. The outer query obtains all products that have been ordered and
subtracts from them the products obtained in the inner query.
14.3 RDF Representation of Multidimensional Data
We are now ready to study two approaches to represent multidimensional
data in RDF, namely, QB and QB4OLAP. Suppose that the Northwind
company wants to analyze sales data against economic and demographic data,
Search WWH ::




Custom Search