sparql - use of curly braces

rdf, semantic-web, sparql

Solution

In many cases, there is no difference

In the examples that you gave, there's no difference. This is actually called out in the specification:

5.2 Group Graph Patterns

In a SPARQL query string, a group graph pattern is delimited with braces: {}. For example, this query's query pattern is a group graph pattern of one basic graph pattern.

PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE  {
          ?x foaf:name ?name .
          ?x foaf:mbox ?mbox .
       }

The same solutions would be obtained from a query that grouped the triple patterns into two basic graph patterns. For example, the query below has a different structure but would yield the same solutions as the previous query:

PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE  { { ?x foaf:name ?name . }
         { ?x foaf:mbox ?mbox . }
       }

But there may be with filters

Where it would be possible to see a difference, though, is with filters:

A constraint, expressed by the keyword FILTER, is a restriction on solutions over the whole group in which the filter appears.

I think that means that

{ ?s ?p ?o1 }
{ ?s ?q ?o2
  filter( !isIri(?o1) )
}

is different from

{
  ?s ?p ?o1 .
  ?s ?q ?o2 .
  filter( !isIri(?o1) )
}

Blank node labels

Another place where it might come into play is blank node labels:

5.1.1 Blank Node Labels

When using blank nodes of the form _:abc, labels for blank nodes are scoped to the basic graph pattern. A label can be used in only a single basic graph pattern in any query.

The validator at sparql.org, for instance, will report a syntax error in:

select * where {
  { _:s ?p ?o }
  { _:s ?p ?o }
}

Syntax error:

Line 3, column 5: Blank node label reuse not allowed at this point: _:s

Problem

Hello I have a simple question regarding sparql queries. does the curly braces have any effect in where clause ? For ex: Is there a difference between ``` { ?s1 ab:wasBornIn "Berlin". ?s1 ?p1 ?o1 } { ?s2 ab:someProperty "SomeLiteral". ?s2 ?p2 ?o2 } ``` AND ``` { ?s1 ab:wasBornIn "Berlin". ?s1 ?p1 ?o1. ?s2 ab:someProperty "SomeLiteral". ?s2 ?p2 ?o2. } ``` Thanks in advance

Original source