Linked Data, Rdf & Sparql
Upcoming SlideShare
Loading in...5
×
 

Linked Data, Rdf & Sparql

on

  • 4,467 views

A 50 minute introduction to RDF, Linked Data and SPARQL.

A 50 minute introduction to RDF, Linked Data and SPARQL.

Statistics

Views

Total Views
4,467
Views on SlideShare
4,467
Embed Views
0

Actions

Likes
13
Downloads
202
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Linked Data, Rdf & Sparql Linked Data, Rdf & Sparql Presentation Transcript

  • Linked Data, RDF & SPARQL Rob Styles Senior Technical Consultant http://creativecommons.org/licenses/by/2.0/uk/
  • Tim Berners Lee on Linked Data at TED, By PhOtOnQuAnTiQuE, CC-BY-NC-SA on Flickr, http://www.flickr.com/photos/photonquantique/3272712288/
  • Linked Data 1. Use URIs as names for things 2. Use HTTP URIs so that people can look up those names. 3. When someone looks up a URI, provide useful information, using the standards (RDF*, SPARQL) 4. Include links to other URIs. so that they can discover more things. Sir Tim Berners-Lee, http://www.w3.org/DesignIssues/LinkedData
  • What is Linked Data?
  • What is The Web of Documents?
  • The Web of Documents A global network of linked documents A place where anyone can say anything about anything A vast collection of human-readable knowledge (and opinion) Documents are linked, but links are not qualified
  • Linked Data 1. Use URIs as names for things 2. Use HTTP URIs so that people can look up those names. 3. When someone looks up a URI, provide useful information, using the standards (RDF*, SPARQL) 4. Include links to other URIs. so that they can discover more things. Sir Tim Berners-Lee, http://www.w3.org/DesignIssues/LinkedData
  • The Web of Documents A global network of linked documents A place where anyone can say anything about anything A vast collection of human-readable knowledge (and opinion) Documents are linked, but links are not qualified
  • The Web of Data A global network of linked statements A place where anyone can say anything about anything A vast collection of machine-readable knowledge (and opinion) Statements are linked, and links are qualified
  • What is RDF?
  • RDF is ... Resource Description Framework http://www.w3.org/RDF/ A simple, powerful, data model Used to define relationships between things Designed to work with the architecture of the web The data model for the Web of Data
  • Allow anyone to say anything about anything
  • http://nssdc.gsfc.nasa.gov/ Apollo 11 Command and nmc/spacecraftDisplay.do? about Service Module id=1969-059A title NASA - NSSDC - Spacecraft - Details name Apollo 11 Command and Service Module published 23 November 2009 launched 16 July 1969 size 15702 mass 28801.0 a Web Page a Spacecraft
  • Apollo 11 Command and launchsite Cape Canaveral Service Module name Apollo 11 Command and Service Module name Cape Canaveral, United States launched 16 July 1969 mass 28801.0 a Spacecraft
  • Resources... Represent things on the web, like web pages Represent things not on the web, like people and places Can represent anything at all Named using URIs (usually)
  • Values... Values can be ‘literal’ values or other resources Literal values are to work with and show users Literal values can have specific types (numbers, dates) and language codes (en-gb, cy-gb) Other resources are URIs to follow and find more data
  • Properties are... The relationship between Resources Named using URIs Described in Schema (or vocabularies, or ontologies)
  • Apollo 11 Command and Cape Canaveral, launchsite Cape Canaveral name Service Module United States
  • Apollo 11 Command and Cape Canaveral, launchsite Cape Canaveral name Service Module United States
  • Subject Property Value Apollo 11 Command and Cape Canaveral, launchsite Cape Canaveral name Service Module United States
  • Subject Property Value Apollo 11 Command and Cape Canaveral, launchsite Cape Canaveral name Service Module United States Subject Property Value
  • Statement or Triple Subject Property Value Apollo 11 Command and Cape Canaveral, launchsite Cape Canaveral name Service Module United States Subject Property Value
  • Statement or Triple Subject Property Value Apollo 11 Command and Cape Canaveral, launchsite Cape Canaveral name Service Module United States Subject Property Value Statement or Triple
  • Simple Rules for Merging URIs name the resources we are describing Two people using the same URI are describing the same thing The same URI in two datasets becomes one URI with all of the properties from both datasets RDF data can use URIs from many different websites
  • http://... Apollo 11 Command and launchsite http://... Cape Canaveral Service Module /1969-059A /cape+cana... name Apollo 11 Command and Service Module name Cape Canaveral, United States launched 16 July 1969 http://... /cape+cana... mass 28801.0 a http://... Spacecraft /Spacecraft latitude N 28° 27' 31'' longitude W 80° 31' 59''
  • http://... Apollo 11 Command and launchsite http://... Cape Canaveral Service Module /1969-059A /cape+cana... name Apollo 11 Command and Service Module name Cape Canaveral, United States launched 16 July 1969 latitude N 28° 27' 31'' mass 28801.0 longitude W 80° 31' 59'' a http://... Spacecraft /Spacecraft
  • Simple Rules for Merging Graphs from several different sources can be merged Resources with the same URI are considered identical No limitations on which graphs can be merged
  • Any RDF can be merged with any other RDF
  • RDF... is a Graph data model XML is a tree data model RDBMS is a table data model can be easily distributed can be easily merged allows anyone say anything about anything is not new the spec is from 1999 the idea stems back to the late 1960s
  • What does RDF look like?
  • Writing RDF Turtle What I’m about to show you N-Triples One statement per line, subset of Turtle, grep compatible RDF/JSON Useful for AJAX Applications and anything with else JSON support RDFa Writing RDF within HTML pages RDF/XML Machine to Machine Transfer De-facto Standard
  • Turtle (TTL) stands for Terse Triple Language
  • Turtle Terse Triple Language (TTL) http://www.w3.org/2007/02/turtle/primer/ A human-readable notation for RDF Provides useful syntax for quickly hand-writing RDF Forms the basis of patterns in SPARQL
  • http://... a http://... /1969-059A /Spacecraft <http://.../1969-059A> a <http://.../Spacecraft> .
  • http://... /1969-059A name Apollo 11 Command and Service Module @prefix space: <http://example.com/space-schema/> . launched 16 July 1969 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/spacecraft/1969-059A> mass 28801.0 a space:Spacecraft ; space:name "Apollo 11 Command and Service Module" ; space:launched "1969-07-16"^^xsd:date ; space:mass 28801.0 . a http://... /Spacecraft
  • http://... launchsite http://... /1969-059A /cape+cana... name Apollo 11 Command and Service Module name Cape Canaveral, United States @prefix space: <http://example.com/space-schema/> . launched 16 July 1969 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/spacecraft/1969-059A> mass 28801.0 a space:Spacecraft ; space:name "Apollo 11 Command and Service Module" ; space:launched "1969-07-16"^^xsd:date ; space:mass 28801.0 . a http://... /Spacecraft
  • http://... launchsite http://... /1969-059A /cape+cana... name Apollo 11 Command and Service Module name Cape Canaveral, United States @prefix space: <http://example.com/space-schema/> . launched 16 July 1969 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/spacecraft/1969-059A> mass 28801.0 a space:Spacecraft ; space:name "Apollo 11 Command and Service Module" ; space:launched "1969-07-16"^^xsd:date ; space:mass 28801.0 . ; a http://... space:launchsite <http://.../cape+cana...> . /Spacecraft
  • http://... launchsite http://... /1969-059A /cape+cana... name Apollo 11 Command and Service Module name Cape Canaveral, United States @prefix space: <http://example.com/space-schema/> . launched 16 July 1969 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/spacecraft/1969-059A> mass 28801.0 a space:Spacecraft ; space:name "Apollo 11 Command and Service Module" ; space:launched "1969-07-16"^^xsd:date ; space:mass 28801.0 . ; a http://... space:launchsite <http://.../cape+cana...> . /Spacecraft <http://.../cape+cana...> space:name "Cape Canaveral, United States"@en-us .
  • How do I SPARQL?
  • SPARQL Query Language for RDF http://www.w3.org/TR/rdf-sparql-query SPARQL Protocol and RDF Query Language Graph pattern based language written the same as Turtle Several queries — Ask; Select; Describe; Construct Read Only still vulnerable to injection, though not as bad as SQL
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Triple Patterns
  • Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" .
  • Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . ?something foaf:name "Sputnik 1" .
  • Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . ?something foaf:name "Sputnik 1" . ?something foaf:name ?name .
  • Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . ?something foaf:name "Sputnik 1" . ?something foaf:name ?name . SELECT ?name WHERE { ?something foaf:name ?name . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Triple Patterns PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label WHERE { ?something rdfs:label ?label . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Triple Patterns PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label WHERE { ?something rdfs:label ?label ; rdf:type space:Discipline . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Triple Patterns PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?launchdate WHERE { ?spacecraft foaf:name “Sputnik 1” . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Example Select PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?subject ?label WHERE { ?subject rdfs:label ?label ; a space:Discipline . }
  • Example Select <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="subject"/> <variable name="label"/> </head> <results> <result> <binding name="subject"> <uri>http://nasa.dataincubator.org/discipline/astronomy</uri> </binding> <binding name="label"> <literal>Astronomy</literal> </binding> </result> <result> <binding name="subject"> <uri>http://nasa.dataincubator.org/discipline/communications</ uri> </binding> <binding name="label"> <literal>Communications</literal>
  • Example Select PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT * WHERE { ?subject rdfs:label ?label ; a space:Discipline . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Example Query PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name ?mass WHERE { ?launch space:launched ?date ; space:spacecraft ?spacecraft . ?spacecraft foaf:name ?name ; space:mass ?mass . FILTER ( ?date >= "1965-01-01"^^xsd:date && ?date <= "1975-12-31"^^xsd:date ) } ORDER BY DESC(?mass) LIMIT 10 OFFSET 10
  • Tip 1: Find all the Properties SELECT DISTINCT ?p WHERE { ?s ?p ?o . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • Tip 2: Find all the Classes SELECT DISTINCT ?type WHERE { ?s a ?type . }
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • /discipline/ space:Discipline a rdfs:label Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R /spacecraft/ space:Spacecraft a 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 space:Launch a /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) space:Launchsite a /launchsite/tyurata space:country U.S.S.R
  • This work is Copyright © 2010 Talis Systems Limited. It is licensed under the Creative Commons Attribution 3.0 Unported License. Full details at: http://creativecommons.org/licenses/by/3.0/ You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). • For any reuse or distribution, you must make clear to others the license terms of this work. • Any of the above conditions can be waived if you get permission from the copyright holder. • Nothing in this license impairs or restricts the author's moral rights. • Some Content in the work may be licensed under different terms, this is noted separately.