Joining patterns through shared variables

Multiple triple patterns join automatically.

0/2 done

Theory

Two patterns sharing a variable form an implicit join:

SELECT ?ninja ?master WHERE {
  ?ninja a :Ninja .
  ?master :teaches ?ninja .
}

The engine returns every (ninja, master) pair where the master teaches a known ninja.

Why it works: a row is kept only if every triple pattern matches with the same binding for any variable that appears more than once. In the example, ?ninja must be the same node in both patterns, which is exactly an inner join on ?ninja. Same idea in tabular form:

PatternBinds
?ninja a :Ninja .?ninja → every Ninja
?master :teaches ?ninja .+ ?master per pair

Reading in progress · 0 of 2 activities done