Construct Queries in SPARQL

So far, we have seen that the answers to questions in SPARQL can take the form of a table, or of a single bit (true/false for Yes/No questions). But in the RDF world, answers to queries can take a more flexible form—an answer could take the form of an RDF graph. This is the idea behind CONSTRUCT—we use the expressive power of RDF in the answer to a query, as well as in the question.

Suppose we wanted to find out all the movie directors in our dataset about movies. One way to find this out would be to write a query that finds out all the people that movies were directed by:

image

?director

:EliaKazan

:FredGuiol

:GeorgeCukor ...

Get Semantic Web for the Working Ontologist, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.