The value of the square brackets "[]" when querying RDF with SPARQL?

I'm new to SPARQL and RDF, and I was wondering what exactly does this mean in SPARQL?

[] vc:n ?vcard . 

Full request

 PREFIX vc: <http://www.w3.org/2006/vcard/ns#> SELECT ?given ?family WHERE{ [] vc:n ?vcard . OPTIONAL {?vcard vc:given-name ?given .} OPTIONAL {?vcard vc:family-name ?family .} } 
+5
source share
2 answers

This cannibalized from my answer to What are parentheses in SPARQL and why is the linked movie database limited to 2500 entries? of which this question may be a duplicate, albeit a bit broader. (He asks two questions, while it asks for only one.) The answer is mostly the references and quotes from the SPARQL specification.

[...] is an empty node

The square brackets are described in the SPARQL 1.1 query language . In particular, see 4.1.4 Syntax for Empty Nodes

4.1.4 Syntax for empty nodes

Empty nodes in graphic templates act as variables, and not as references to specific empty nodes in the requested data.

Empty nodes are indicated by either the label form, for example, "\_:abc" , or the abbreviated form "[]" . An empty node that is used only in one place in the query syntax can be specified using [] . The unique space node will be used to form the triple pattern. The empty node labels are written as "_:abc" for the space node with the label "abc". The same empty node label cannot be used in two different main graphic templates in the same request.

The [:p :v] construct can be used in triple patterns. It creates a node form, which is used as the subject of all contained pairs of the predicate object. The created empty node can also be used in additional triple patterns in objects and objects.

Next two forms

 [ :p "v" ] . [] :p "v" . 

highlight the unique empty node label (here "b57") and the scripture is equivalent:

 _:b57 :p "v" . 

This highlighted empty node label can be used as an object or an object of additional triple patterns. For example, as a topic:

 [ :p "v" ] :q "w" . 

which is equivalent to two triples:

 _:b57 :p "v" . _:b57 :q "w" . 

and as an object:

 :x :q [ :p "v" ] . 

which is equivalent to two triples:

 :x :q _:b57 . _:b57 :p "v" . 
+7
source

[] is the space of the node in the request. It acts like a named variable, except that you cannot use it in a SELECT or FILTER project or anywhere you need to specify this variable. You can replace [] with a named variable using a name that is not used anywhere in the query. SELECT * will add it, but otherwise it will be the same query.

+4
source

Source: https://habr.com/ru/post/1200178/


All Articles