Skip to content

Commit

Permalink
Update documentation for DECONSTRUCT
Browse files Browse the repository at this point in the history
Add documentation describing how the DECONSTRUCT statement can be used.
  • Loading branch information
xllora committed Sep 3, 2017
1 parent 70218c5 commit e11215a
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion docs/bql.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ The where clause will bind to all available predicates. Each binding will
then be used in the construct part to create the new triples.

A more elaborate example would be to create a new fact `grandparent` into
the destination graphs by properly extracting graph patterns via the where
the destination graphs by properly extracting graph patterns via the `WHERE`
clause.

```
Expand Down Expand Up @@ -517,3 +517,51 @@ number of blank nodes. The syntax is always the same, they all start with
the prefix `_:` followed by a logical ID. On insertion of each new fact,
BQL guarantees a new unique blank node will be generated by each of them.
Example of multiple blank nodes generated at once are `_:v0`, `_:v1`, etc.


## Removing complex facts out of existing graphs using existing statements

In some cases you want to create remove facts--remove existing triples---in an
existing graph or graphs based on facts existing on the same or other graphs.
Deconstructing facts requires two steps: (1) querying for the information that
is going to be used to remove facts, and (2) how the facts to be removed are
going to be assembled. An illustrative example is:

```
DECONSTRUCT {
?s ?p ?o
}
IN ?dest
FROM ?src
WHERE {
?s ?p ?o
};
```

The above example would remove all immutable triples in the `?dest` graph that
were found in the `?src` graph. As the `CONSTRUCT` statement, the `DECONTRUCT`
statement supports multiple graph on the `IN` and `FROM` clauses of the
statement.

Following the example used in the previous section, we could use the
`DECONSTRUCT` to remove `grandparent` facts in a destination graph built from
a source graphs by properly extracting graph patterns via the `WHERE`
clause.

```
DECONSTRUCT {
?ancestor "grandparent"@[] ?grandchildren
}
INTO ?dest
FROM ?src
WHERE {
?ancestor "parent"@[] ?c .
?c "parent"@[] ?grandchildren
};
```

The `DECONSTRUCT` statement does not support neither the blank node notation
nor the reification syntax. Those are used to refer to newly created nodes
introduced by the statement, which makes sends on `CONSTRUCT` statements.
However, `DECONSTRUTC` statements already have all the required information
to assemble the triples to remove.

0 comments on commit e11215a

Please sign in to comment.