google / badwolf

Temporal graph store abstraction layer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add DECONSTRUCT query to BQL

xllora opened this issue · comments

Deconstruct queries allow to removed derived facts from a graphs. The facts are defined based on the bindings provided in the WHERE clause. Basic filtering capabilities are provided by adding a HAVING clause. This is the complementary statement for CONSTRUCT introduced in issue #45.

DECONSTRUCT { 
       ?p "grandmother of"@[] ?g .
       ?g "grandchild of"@[]  ?p
}
AT ?graph1, ?graph2
FROM ?graph3, ?graph4
WHERE {
       ?p         "parent of"@[] ?parent .
       ?parent    "parent of"@[] ?g .
       ?p         "gender"@[]    ?gender 
}
HAVING ?gender == /gender<male>;

It is worth mention that the abover query could be simplified as shown below. Never the less, the goal what to show the full structure of a CONSTRUCT query.

DECONSTRUCT {
       ?p "grandmother of"@[] ?g .
       ?g "grandchild of"@[]  ?p
}
AT ?graph1, ?graph2
FROM ?graph3, ?graph4
WHERE {
       ?p         "parent of"@[] ?parent .
       ?parent    "parent of"@[] ?g .
       ?p         "gender"@[]    /gender<male>
};

_ are not allowed on DECONSTRUCT clauses.