際際滷

際際滷Share a Scribd company logo
SPARQL 1.1
Update Language

SPARQL 1.1 Update
Overview
 SPARQL 1.1 Update Overview
 Graph Updates






Insert
Delete
Delete/Insert
Load
Clear

 Graph Management
 Create
 Drop
 Copy, Move, Add
SPARQL 1.1 Update

#2
SPARQL 1.1 Update Overview
 SPARQL 1.1 increases further the prominence of
named graphs in RDF
 It offers three ways to affect explicitly specified data
within a graph (or graphs):
 INSERT DATA
 DELETE DATA
 DELETE/INSERT  WHERE 

 It also offers two ways to further change the data
within a graph:
 LOAD  CLEAR

 It offers a set of graph management operations:
 CREATE  DROP  COPY  MOVE  ADD
SPARQL 1.1 Update

#3
INSERT DATA
 The most basic part of SPARQL 1.1 Update is to allow
data to be inserted into a store, e.g.:
INSERT DATA {ou:barry foaf:givenName "Barry";
foaf:familyName "Norton";
foaf:mbox <mailto:barry.norton@sti2.at>}

 While a default graph may be supported, it is common
to manage data in a named graph:
INSERT DATA { GRAPH <http://ontotext.com/ns#>
{onto:barry1 foaf:givenName "Barry";
foaf:familyName "Bishop";
foaf:mbox <barry.bishop@ontotext.com>}}
SPARQL 1.1 Update

#4
DELETE DATA
 SPARQL 1.1 Update also allows deletion of explicitly
described triples:
DELETE DATA {sti:barry foaf:mbox
<mailto:barry.norton@sti2.at>}

 Note that no blank nodes are allowed in these DELETE
queries since these match any resource in SPARQL
(Cf.:
SELECT ?mbox WHERE {_:barry foaf:mbox ?mbox}
mbox
<mailto:b.j.norton@open.ac.uk>
SPARQL 1.1 Update

)
#5
DELETE/INSERT
 SPARQL 1.1 extends the use of graph patterns for use
in parallel INSERT and DELETE, according to matches,
e.g.:
DELETE {?barry foaf:mbox <mailto:barry.norton@sti2.at>}
INSERT { GRAPH <http://ontotext.com/ns#>
{onto:barry foaf:givenName ?forename;
foaf:familyName ?surname;
foaf:mbox <mailto:barry.norton@ontotext.com>}}
WHERE {?barry foaf:mbox <mailto:barry.norton@sti2.at>;
foaf:givenName ?forename;
foaf:familyName ?surname}
}
SPARQL 1.1 Update

#6
DELETE WHERE
 SPARQL 1.1 offers a simpler form of INSERT/DELETE
when just deleting:
DELETE {?barry foaf:mbox <mailto:barry.norton@sti2.at>}
WHERE {?barry foaf:mbox <mailto:barry.norton@sti2.at>}

DELETE
WHERE {?barry foaf:mbox <mailto:barry.norton@sti2.at>}

SPARQL 1.1 Update

#7
USING/WITH
 SPARQL Update uses USING (NAMED) in role of
FROM (NAMED) with respect to WHERE clauses
INSERT { GRAPH <http://ontotext.com/ns#>
{?barry foaf:nick "Baz"}}
USING <http://ontotext.com/ns#>
WHERE {?barry foaf:givenName "Barry"}

 It also offers a simpler way to deal with the same
named graph throughout a DELETE/INSERT query
WITH <http://ontotext.com/ns#>
INSERT {?barry foaf:nick "Baz"}
WHERE {?barry foaf:givenName "Barry"}
SPARQL 1.1 Update

#8
LOAD/CLEAR
 SPARQL 1.1 allows an RDF graph to be loaded from a
URL, e.g.:
LOAD <http://xmlns.com/foaf/spec/20100809.rdf>

 The graph can also be loaded as a named graph, e.g.:
LOAD
<http://dl.dropbox.com/u/3954923/ontotext.rdf.ttl>
INTO <http://ontotext.com/ns#>

 A named graph can also be cleared of all triples, e.g.:
CLEAR GRAPH <http://ontotext.com/ns#>
SPARQL 1.1 Update

#9
Graph Management 1/2
 A new named graph can be explicitly created, e.g.:
CREATE GRAPH <http://ontotext.com/ns#>

 A new named graph can be dropped (different from
clearing if empty graphs are supported), e.g.:
DROP GRAPH <http://ontotext.com/ns#>

 We can also CLEAR, CREATE and DROP:
DEFAULT and ALL
 We also LOAD, CLEAR, CREATE and DROP with SILENT
SPARQL 1.1 Update

#10
Graph Management 2/2
 The recommendation for SPARQL Update may or
may not also include:
 COPY TO , e.g.:
COPY GRAPH <http://www.example.com/v1#>
TO GRAPH <http://www.example.com/v2#>

 MOVE TO , e.g.:
MOVE GRAPH <http://www.example.com/draft#>
TO GRAPH <http://www.example.com/v1#>

 ADD TO , e.g.:
ADD GRAPH <http://ontotext.com/ns#>
TO GRAPH <http://sirma.bg/ns#>
SPARQL 1.1 Update

#11

More Related Content

ESWC SS 2012 - Monday Tutorial 2 Barry Norton: SPARQL 1.1 Update Language

  • 2. Overview SPARQL 1.1 Update Overview Graph Updates Insert Delete Delete/Insert Load Clear Graph Management Create Drop Copy, Move, Add SPARQL 1.1 Update #2
  • 3. SPARQL 1.1 Update Overview SPARQL 1.1 increases further the prominence of named graphs in RDF It offers three ways to affect explicitly specified data within a graph (or graphs): INSERT DATA DELETE DATA DELETE/INSERT WHERE It also offers two ways to further change the data within a graph: LOAD CLEAR It offers a set of graph management operations: CREATE DROP COPY MOVE ADD SPARQL 1.1 Update #3
  • 4. INSERT DATA The most basic part of SPARQL 1.1 Update is to allow data to be inserted into a store, e.g.: INSERT DATA {ou:barry foaf:givenName "Barry"; foaf:familyName "Norton"; foaf:mbox <mailto:barry.norton@sti2.at>} While a default graph may be supported, it is common to manage data in a named graph: INSERT DATA { GRAPH <http://ontotext.com/ns#> {onto:barry1 foaf:givenName "Barry"; foaf:familyName "Bishop"; foaf:mbox <barry.bishop@ontotext.com>}} SPARQL 1.1 Update #4
  • 5. DELETE DATA SPARQL 1.1 Update also allows deletion of explicitly described triples: DELETE DATA {sti:barry foaf:mbox <mailto:barry.norton@sti2.at>} Note that no blank nodes are allowed in these DELETE queries since these match any resource in SPARQL (Cf.: SELECT ?mbox WHERE {_:barry foaf:mbox ?mbox} mbox <mailto:b.j.norton@open.ac.uk> SPARQL 1.1 Update ) #5
  • 6. DELETE/INSERT SPARQL 1.1 extends the use of graph patterns for use in parallel INSERT and DELETE, according to matches, e.g.: DELETE {?barry foaf:mbox <mailto:barry.norton@sti2.at>} INSERT { GRAPH <http://ontotext.com/ns#> {onto:barry foaf:givenName ?forename; foaf:familyName ?surname; foaf:mbox <mailto:barry.norton@ontotext.com>}} WHERE {?barry foaf:mbox <mailto:barry.norton@sti2.at>; foaf:givenName ?forename; foaf:familyName ?surname} } SPARQL 1.1 Update #6
  • 7. DELETE WHERE SPARQL 1.1 offers a simpler form of INSERT/DELETE when just deleting: DELETE {?barry foaf:mbox <mailto:barry.norton@sti2.at>} WHERE {?barry foaf:mbox <mailto:barry.norton@sti2.at>} DELETE WHERE {?barry foaf:mbox <mailto:barry.norton@sti2.at>} SPARQL 1.1 Update #7
  • 8. USING/WITH SPARQL Update uses USING (NAMED) in role of FROM (NAMED) with respect to WHERE clauses INSERT { GRAPH <http://ontotext.com/ns#> {?barry foaf:nick "Baz"}} USING <http://ontotext.com/ns#> WHERE {?barry foaf:givenName "Barry"} It also offers a simpler way to deal with the same named graph throughout a DELETE/INSERT query WITH <http://ontotext.com/ns#> INSERT {?barry foaf:nick "Baz"} WHERE {?barry foaf:givenName "Barry"} SPARQL 1.1 Update #8
  • 9. LOAD/CLEAR SPARQL 1.1 allows an RDF graph to be loaded from a URL, e.g.: LOAD <http://xmlns.com/foaf/spec/20100809.rdf> The graph can also be loaded as a named graph, e.g.: LOAD <http://dl.dropbox.com/u/3954923/ontotext.rdf.ttl> INTO <http://ontotext.com/ns#> A named graph can also be cleared of all triples, e.g.: CLEAR GRAPH <http://ontotext.com/ns#> SPARQL 1.1 Update #9
  • 10. Graph Management 1/2 A new named graph can be explicitly created, e.g.: CREATE GRAPH <http://ontotext.com/ns#> A new named graph can be dropped (different from clearing if empty graphs are supported), e.g.: DROP GRAPH <http://ontotext.com/ns#> We can also CLEAR, CREATE and DROP: DEFAULT and ALL We also LOAD, CLEAR, CREATE and DROP with SILENT SPARQL 1.1 Update #10
  • 11. Graph Management 2/2 The recommendation for SPARQL Update may or may not also include: COPY TO , e.g.: COPY GRAPH <http://www.example.com/v1#> TO GRAPH <http://www.example.com/v2#> MOVE TO , e.g.: MOVE GRAPH <http://www.example.com/draft#> TO GRAPH <http://www.example.com/v1#> ADD TO , e.g.: ADD GRAPH <http://ontotext.com/ns#> TO GRAPH <http://sirma.bg/ns#> SPARQL 1.1 Update #11