SPARQL is a standard query language for RDF that has undergone two iterations (1.0 and 1.1) through the W3C process. SPARQL 1.1 includes updates to RDF stores, subqueries, aggregation, property paths, negation, and remote querying. It also defines separate specifications for querying, updating, protocols, graph store protocols, and federated querying. Apache Jena provides implementations of SPARQL 1.1 and tools like Fuseki for deploying SPARQL servers.
2. SPARQL is ...
● A standard query language for RDF
– And now with update of RDF stores
● Product of W3C Process
● Submissions
● “members”
● Working groups
● Consensus (amongst the active participants)
● Widely implemented
3. History 1.0
● SPARQL 1.0
– Timescale: 2004 – 2008
● 2 years late
– Lots of choices for starting points
– Controversies
● Syntax
● Named graphs
● Algebra
5. SPARQL 1.0 Example
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix stock: <http://example.org/stock#> .
stock:book1 dc:title "SPARQL Query Language Tutorial" .
stock:book2 dc:title "SPARQL Query Language (2nd ed)" .
stock:book3 dc:title "Moving from SQL to SPARQL" .
stock:book4 dc:title "Applying XQuery" .
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX stock: <http://example.org/stock#>
SELECT ?book ?title
{
?book dc:title ?title .
FILTER (regex(?title, "SPARQL"))
}
--------------------------------------------------
| book | title |
==================================================
| stock:book3 | "Moving from SQL to SPARQL" |
| stock:book2 | "SPARQL Query Language (2nd ed)" |
| stock:book1 | "SPARQL Query Language Tutorial" |
--------------------------------------------------
6. SPARQL 1.0
● Experimentation for new features started
before the first standard was published
– But you can't wait until “completely complete”
● Issues
– Counting
– Standard function library
– Hard-to-use negation
– Query only, no update
– Only a “note” about a JSON output
7. History 1.1
● SPARQL 1.1
– Timescale : 2009 – 2013
● 2 years late …
– Controversies
● Negation
● Property paths
● Graphs … REST ...
8. SPARQL 1.1
●
SPARQL 1.1 Query
● SPARQL 1.1 Update
●
SPARQL 1.1 Protocol
● SPARQL 1.1 Graph Store Protocol
●
SPARQL 1.1 Service Description
● SPARQL 1.1 Federated Query
●
SPARQL 1.1 Query Results JSON Format
● SPARQL 1.1 Query Results CSV and TSV Formats
●
SPARQL Query Results XML Format
●
SPARQL 1.1 Entailment Regimes
12. SPARQL 1.1 Update
● Fine grain graph manipulations
– Act on a “graph store”
– Add and remove graphs
– Act on the contents of graphs
– Quad centric
● LOAD, DROP, CREATE
● INSERT, DELETE
– Data and patterns
● One request is multiple operations
13. Data Operations
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE DATA { <http://example/abc> foaf:name "DEF" . } ;
INSERT DATA { <http://example/abc> foaf:name "ABC" . } ;
15. SPARQL 1.1 Graph Store Protocol
● Simple way to manage a store (RDF Dataset)
● GET, PUT, POST, DELETE
● Naming
– Same server
http://server/store/graph1
– Different server
http://server/store?graph=http://example/g1
http://server/store?graph=http%3A//example/g1
http://server/store?default