More interesting examples

Some more interesting examples, exploring composition and filters.

Composition is important because the mechanisms here are related to what 
SHACL calls pre-binding and is provided in various ways in most 
toolkits.  Also c.f. SQL Correlated subqueries

The FILTER tests are "?a = ?b" on URIs to make tests just about RDFterms.

The real world would include FILTER ( ?x < ?y ) for literals ?x and ?y.

 Andy

Data:
Graph
 :s :p :v .
 :t :r :w .

-----------------------------------
Example 6:

SELECT ?x WHERE {
   ?x :p ?v .
   FILTER ( EXISTS {
     ?x :p :v .
       MINUS { ?x :p ?w . FILTER(?w = ?v) } # or sameTerm()
     } )
   }

Specification   { { (x,:s) } }
Proposal A      { }
Proposal B      { { (x,:s) } }
Expected        { { (x,:s) } }

-----------------------------------
Example 7:

SELECT ?x WHERE {
   :s :p ?v .
   FILTER ( EXISTS {
     :s :p ?v . FILTER ( ?w = ?v )
   }

Specification   { { (x,:s) } }
Proposal A      { { (x,:s) } }
Proposal B      { { (x,:s) } }
Expected        { { (x,:s) } }

-----------------------------------
Example 8:

SELECT ?x WHERE {
   :s :p ?v .
   FILTER ( EXISTS {
      { :s :p ?w . FILTER ( ?w = ?v ) }
        UNION
      { :s :p ?w . FILTER ( ?w = ?v ) }
   }
}

Specification   { { (x,:s) } }
Proposal A      { }
Proposal B      { { (x,:s) } }
Expected        { { (x,:s) } }

-----------------------------------
-----------------------------------

Data:
GRAPH :g {
   :s :p :v .
   :t :r :w .
}

-----------------------------------
Example 9:
   see example 7

PREFIX : <http://example/>

SELECT ?x WHERE {
   GRAPH :g {
     ?x :p ?v .
     FILTER ( EXISTS {
       ?x :p ?w. FILTER ( ?w = ?v )
     } )
   }
}

Specification   { { (x,:s) } }
Proposal A      { { (x,:s) } }
Proposal B      { { (x,:s) } }
Expected        { { (x,:s) } }

-----------------------------------
Example 10:

SELECT ?x WHERE {
   ?x :p ?v .
   FILTER ( EXISTS {
     GRAPH :g {
       ?x :p ?v
     }
   } )
}

Specification   { { (x,:s) } }
Proposal A      { { (x,:s) } }
Proposal B      { { (x,:s) } }
Expected        { { (x,:s) } }

-----------------------------------
Example 11:

SELECT ?x WHERE {
     ?x :p ?v .
     FILTER ( EXISTS {
       GRAPH :g {
         ?x :p ?w. FILTER ( ?w = ?v )
     } )
   }
}

Specification   { { (x,:s) } }
Proposal A      { }
Proposal B      { { (x,:s) } }
Expected        { { (x,:s) } }

Received on Wednesday, 30 November 2016 12:01:08 UTC