SPARQL/Extensoins/Subqueries

From W3C Wiki
Jump to: navigation, search

There are several ways in which a SPARQL (sub)query might be embedded in another query.

  • A) A SELECT query could be embedded in a query's query pattern, joining its bindings with those of the parent query.
  • B) A ASK query could be used in a FILTER as a boolean condition (perhaps combined with an EXISTS operator.
  • C) A CONSTRUCT or DESCRIBE query could be used in a FROM or FROM NAMED clause to supply part of a query's RDF dataset.
  • D) OpenLink Virtuoso supports SELECT subqueries in all places where group patterns are allowed. Virtuoso also supports the AS keyword to rename expression as bindings that can be joined with and projected in a parent query. Future versions of Virtuoso will support the second two subquery forms mentioned above. Virtuoso also intends to implement named SPARQL views that will be similar to named SQL views; these views will be implemented as macros so any given occurrence of a view in a query will be replaced with occurrence of the body of the view in same place (with adjusted variable names). If implemented this way, view declarations can not contain invocations of the view itself, but this limitation will allow a global optimization of the query with all invoked views without writing full-scale DATALOG infrastructure.