Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COMPSCI 752

Big Data Management

Strategic Exercise 5

Graph Queries

Application Domain. For all the exercises we are looking at an application domain where customers buy parts of products, and suppliers supply parts of products. Parts can also be parts of other parts. Customers, Suppliers, and Parts may have various properties. As an example for the application domain we consider the following property graph G:

Exercise 1 - Regular Path Queries.

For each of the following English language queries,

Write them down as regular path queries.

Evaluate them on the property graph G above.

a. List all pairs of customers who have bought the same part.

b. List all pairs of customers c1  and c2  for which there is some customer c that has bought the same part as c1  and the same part as c2 .

c. List a pair of customers c1  and c2  whenever they have bought the same part, or there is some customer c that has bought the same part as c1  and the same part as c2 .

d. We say that two customers c and cI  are linked through a chain c1 , . . . , cn  of customers if c = c1 , cI  = cn  and for  1 s i s n _ 1 there is some part that is bought by ci  and ci1 . List all pairs of customers that are linked through some chain.


e. List a pair of customer and supplier whenever the customer has bought apart the supplier supplied.

f. List a pair of customer and supplier whenever the customer has bought apart the supplier supplied or bought.

g. List a pair of customer and supplier whenever the customer has bought apart the supplier supplied and bought.

h. List a customer whenever they have bought a part that is part of some part.

Exercise 2 - Conjunctive Graph Queries.

For each of the following English language queries,

Write them down as conjunctive graph query.

Evaluate them on the property graph G above.

a. List all pairs of customers who have bought the same part.

b. List all pairs of customers c1  and c2  for which there is some customer c that has bought the same part as c1  and the same part as c2 .

c. List a pair of customers c1  and c2  whenever they have bought the same part, or there is some customer c that has bought the same part as c1  and the same part as c2 .

d. We say that two customers c and cI  are linked through a chain c1 , . . . , cn  of customers if c = c1 , cI  = cn  and for  1 s i s n _ 1 there is some part that is bought by ci  and ci1 . List all pairs of customers that are linked through some chain.

e. List a pair of customer and supplier whenever the customer has bought apart the supplier supplied.

f. List a pair of customer and supplier whenever the customer has bought apart the supplier supplied or bought.

g. List a pair of customer and supplier whenever the customer has bought apart the supplier supplied and bought.

h. List a customer whenever they have bought a part that is part of some part.

Exercise 3 - More expressive Languages.

For the application domain above,

a. Find a conjunctive regular path query that is neither a conjunctive graph query nor a regular graph query, and evaluate it on G.

b. Find a union of conjunctive regular path query that is not a conjunctive regular path query, and evaluate it on G

c. Find a relational algebra (RA) query that cannot be expressed by any of the other query languages we have discussed.

Exercise 4 - Regular Property Graph Logic.

For each of the following English language queries,

Write them down as regular property graph logic query or its extensions.

Evaluate them on the property graph G above.

a. List all suppliers who supply some type of gun.

b. List all suppliers who supply some type of gun, or some part that has been bought by a customer from ’MI6’ .

c. List all suppliers who have bought some part cheaper than what they supplied it for.

d. Return teams of two customers and one supplier together with the average price of pur- chasing a product by the customers, whenever that average price is lower than the price the product was supplied by the supplier.

Exercise 5 - Regular Property Graph Algebra.

For each of the following English language queries write them down as a regular property graph algerba query.

a. List all suppliers who supply some type of gun.

b. List all suppliers who supply some type of gun, or some part that has been bought by a customer from ’MI6’ .

c. List all suppliers who have bought some part cheaper than what they supplied it for.