Open BenjaminHofstetter opened 2 years ago
Related to nested CONSTRUCT queries (#33)
I assume the semantics accumulate a single output graph, i.e.
WHERE {
?s1 ex:prop1 ?o1
}
matches ex:prop1
in the original dataset,
CONSTRUCT {
?s1 ex:prop1 ?o1
}
adds (in this case, identical) triples to the output graph
WHERE {
?s2 ex:prop2 ?o2
}
matches ex:prop2
in the same (original) dataset,
CONSTRUCT {
?s2 ex:prop2 ?o2
}
adds these triples to the same constructed output graph
@BenjaminHofstetter interesting proposal.
I use them often. The best thing is I describe what I do. I use SHACL shapes in my application. And I derive SPARQL construct queries from these Shapes. When the query returns I validate the result with these Shapes. With that approach I can (re)use the shapes and the derived query everywhere. e.g. I have a Person Shape and UI Metadata Shape (for UI display things like color and icon). I Can then derive the SPARQL queries and execute them and merge the datasets or I can merge the construct query into one query (what I am actually doing right now).
Why?
The context of this request are web applications and generated queries. In applications I can merge the result of several construct queries into one dataset. The advantage of having many smaller queries is reusability of such a query. And these queries are smaller and have a well defined function e.g. fetch a person or fetch a persons friends. These queries are better maintainable because the code to generate such a query is not very complex.
But for web apps it much better to have just one query and not many. To fetch all the required data in one request. If i generate just one construct query to fetch all the data ...
It would be nice to send many construct in one query and get one dataset back.
Previous work
I solved this with SPARQL 1.1 with a function that merges construct queries into one query. It works like this.
The solution works and is very convenient to use. The reusability of the queries provides a lot of flexibility. The drawback of this solution is the code to merge construct queries. it uses a query parser and renaming variables is not that nice.
Proposed solution
Just send many construct queries in one request get a merged graph back.
Considerations for backward compatibility