Notes on this page are based on the “SPARQL Protocol and RDF Query Language” slides of the “Logics for Data and Knowledge Representation” series from Fausto Giunchiglia and Feroz Farazi at the University of Trento.

SPARQL is a language to expressing queries to gather information from data represented in the Resource Description Framework (RDF). Often, SPARQL queries contain a basic graph pattern (a set of subjectobjectpredicate triples) with RDF terms substitued for variables, and return a subgraph of the RDF data graph.

### Terminologies

RDF Terms:

Given that I is the set of all IRIs, L is the set of all RDF literals and B is the set of all blank nodes in an RDF graph. Within the graph the set of all RDF terms, T = ILB.

RDF Dataset:

D = {G, (I₁, G₁), (I₂,G₂), … (Iₖ, Gₖ)} where G is the default graph, (I₁, G₁) are named graphs and i = 1 to k.

• An RDF dataset always contains a default graph, which does not have a name.
• It contains zero or more named graphs
• Each named graph is identified by a URI

Query Variable:

A query variable, v ∈ V, where V is infinite and V ∩ T = ∅

Triple Pattern:

A triple pattern P ∈ {(T U V) x (I U V) x (T U V)}

Solution Mapping:

A solution mapping is a partial function M:V -> T where V is the query variable and T is the set of all RDF terms.

Solution Sequence:

A list of soluations which might be unordered. Number of soluations might be zero, one, or more.

Solution Sequence Modifier:

Order by, projection, distinct, reduced, offset, limit

### Query

Dataset:
paper1:        :title        “Semantic Matching”

Query expression:
SELECT        ?title        WHERE        { :paper1 :title ?title. }

Query result:
title        “Semantic Matching”