Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: University of Florida Libraries, Linked Data Working Group, Tech Talk, 15 March 2016

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 13 Anzeige

Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: University of Florida Libraries, Linked Data Working Group, Tech Talk, 15 March 2016

Herunterladen, um offline zu lesen

Notes, examples, and cheat sheets for using SPARQL to query RDF linked data

Notes, examples, and cheat sheets for using SPARQL to query RDF linked data

Anzeige
Anzeige

Weitere Verwandte Inhalte

Diashows für Sie (20)

Andere mochten auch (20)

Anzeige

Ähnlich wie Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: University of Florida Libraries, Linked Data Working Group, Tech Talk, 15 March 2016 (20)

Aktuellste (20)

Anzeige

Notes from the Library Juice Academy courses on “SPARQL Fundamentals”: University of Florida Libraries, Linked Data Working Group, Tech Talk, 15 March 2016

  1. 1. Tech Talk BIBFRAMEWorking Group 15 March 2016 Notes from the Library Juice Academy courses on “SPARQL Fundamentals” Allison Jai O’Dell | AJODELL@ufl.edu
  2. 2. SPARQL The SPARQL Protocol and RDF Query Language (SPARQL) is “a semantic query language for databases, able to retrieve and manipulate data stored in Resource Description Framework (RDF) format” --Wikipedia
  3. 3. Turtle Syntax SPARQL uses the triple pattern and Turtle syntax Turtle: Terse RDF Triple Language <http://www.example.com/uri> namespace:element “literal” . “literal”@en  Literal with a language tag “literal”^^xsd:integer  Typed literal
  4. 4. Basic SPARQL Query PREFIX dct: <http://purl.org/dc/terms/> SELECT ?subject WHERE { <http://www.worldcat.org/oclc/704257552> dct:creator ?subject . } PREFIX specifies namespaces SELECT specifies solutions to return WHERE specifies triple & graph patterns to query
  5. 5. DISTINCT Modifier PREFIX dct: <http://purl.org/dc/terms/> SELECT DISTINCT ?subject WHERE { ?title dct:subject ?subject . } DISTINCT de-duplicates solutions
  6. 6. More Modifiers PREFIX dct: <http://purl.org/dc/terms/> SELECT ?title ?subject WHERE { ?title dct:subject ?subject . } ORDER BY ?subject LIMIT 5 OFFSET 10 ORDER BY specifies how to sort solutions. OFFSET causes the solutions generated to start after the specified number of solutions. LIMIT puts an upper bound on the number of solutions returned.
  7. 7. Federated Queries PREFIX dct: <http://purl.org/dc/terms/> SELECT DISTINCT ?subject WHERE { SERVICE <http://dbpedia.org/snorql> { ?title dct:subject ?subject . } } SERVICE lets you run federated queries over multiple endpoints
  8. 8. Helpful Operators • Conjunction / Boolean “and” A . B • Disjunction / Boolean “or” {A} UNION {B} • Negation A MINUS {B}
  9. 9. Property Paths • path1/path2 Sequence path (pipe) • ^path1 Inverse path (object to subject) • path1|path2 Alternative path (either path1 or path2) • path1* path1 repeated zero or more times • path1+ path1 repeated one or more times • path1? Zero or one, e.g., path1 is optional • !(set) Negation
  10. 10. Slightly complicated SPARQL Query # British Museum http://collection.britishmuseum.org/sparql PREFIX crm: <http://erlangen-crm.org/current/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX ecrm: <http://erlangen-crm.org/current/> PREFIX bmo: <http://collection.britishmuseum.org/id/ontology/> SELECT ?physdesc { ?henry skos:prefLabel "Henry Spencer Ashbee" . ?henry ^ecrm:P51_has_former_or_current_owner/ bmo:PX_physical_description ?physdesc . }
  11. 11. Four Query Forms • SELECT • CONSTRUCT Construct new RDF triples & graphs based on patterns and existing data • ASK Ask whether or not a pattern matches the data; result is true or false • DESCRIBE Describe the resources matched by given variables
  12. 12. CONSTRUCT Query PREFIX dbr: <http://dbpedia.org/resource/> PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { dbr:Mindy_Kaling foaf:knows ?who . ?who foaf:knows ?more . } WHERE { SERVICE <http://dbpedia.org/sparql> { dbr:The_Mindy_Project dbo:starring ?who . ?who ^dbo:starring/dbo:starring ?more . } }
  13. 13. Let’s have a go. http://dbpedia.org/snorql/ http://collection.britishmuseum.org/sparql

×