On 09/05/17 15:44, tina sani wrote:
In which which situation one should use nested SPARQL queries? I mean, how we could know in this situation we should use SPARQL queries?
If you are able to express your queries satisfactorily without them then you don't need them and don't worry about them.
Nested queries can be helpful, for example, to give you extra control of performance or to apply limit/offsets with more selectivity.
Because of Sparql's bottom up evaluation model then in effect a nested select runs first and passes bindings to the outer query. That means you can force some amount of execution order by using nested select.
The use case which I see most often is when you want to retrieve properties of some large set of resources via SELECT but want to page through those resources. If you put the query which identifies the target resources in an inner select with a LIMIT/OFFSET then you can fix the number of resources examined. You then put the elements of the queries that retrieve properties of the resources in the outer query. That way if some of those properties are multi valued (thus giving multiple rows for a single root resource) you still get whole resource descriptions and the number of described resources corresponds to your LIMIT and isn't affected by the multivalued properties.
Dave
