CONSTRUCT — rewrite the graph

Build new triples from old patterns.

0/2 done

Theory

CONSTRUCT projects results into a new triple template:

CONSTRUCT { ?n :learnsFrom ?m }
WHERE    { ?m :teaches ?n }

It's a cheap way to materialize inferred triples.

Useful graph-rewriting patterns you'll see in real systems: materialising OWL inferences without a full reasoner; reshaping one vocabulary into another (e.g. schema:authordcterms:creator); building a small per-request view of a huge graph; and exporting a subset for downstream consumers. Same query language for read, validate and transform.

CONSTRUCT vs CONSTRUCT-WHERE vs UPDATE

  • CONSTRUCT { template } WHERE { pattern } — the general form; the template can differ from what you matched.
  • CONSTRUCT WHERE { pattern } — shorthand when the output triples are exactly the matched ones (a graph extract).
  • INSERT { ... } WHERE { ... } (SPARQL UPDATE) — when you want to persist the new triples into the store rather than return them. CONSTRUCT is read-only and side-effect-free; prefer it for views and pipelines, and reserve INSERT for deliberate, audited materialisation.

Reading in progress · 0 of 2 activities done