linked data, rdf & sparql

Post on 11-May-2015

3.689 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

http://creativecommons.org/licenses/by/2.0/uk/

Linked Data, RDF & SPARQLRob StylesSenior Technical Consultant

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 isLinked Data?

What isThe 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 Frameworkhttp://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 anyoneto say anythingabout anything

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 Service Module Cape Canaveral Cape Canaveral,

United States namelaunchsite

Apollo 11 Command and Service Module Cape Canaveral Cape Canaveral,

United States namelaunchsite

Subject Property Value

Apollo 11 Command and Service Module Cape Canaveral Cape Canaveral,

United States namelaunchsite

Subject Property Value

Subject Property Value

Apollo 11 Command and Service Module Cape Canaveral Cape Canaveral,

United States namelaunchsite

Subject Property Value

Subject Property Value

Statement or Triple

Apollo 11 Command and Service Module Cape Canaveral Cape Canaveral,

United States namelaunchsite

Subject Property Value

Subject Property Value

Statement or Triple

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

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 modelXML is a tree data modelRDBMS is a table data model

can be easily distributed

can be easily merged

allows anyone say anything about anything

is not newthe spec is from 1999the idea stems back to the late 1960s

What does RDF look like?

Writing RDF

TurtleWhat I’m about to show you

N-TriplesOne statement per line, subset of Turtle, grep compatible

RDF/JSONUseful for AJAX Applications and anything with else JSON support

RDFaWriting RDF within HTML pages

RDF/XMLMachine to Machine TransferDe-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://.../1969-059A

http://.../Spacecraft

a

Apollo 11 Command and Service Modulename

16 July 1969launched

28801.0mass

<http://example.com/spacecraft/1969-059A>

a space:Spacecraft ;

space:name "Apollo 11 Command and Service Module" ;

space:launched "1969-07-16"^^xsd:date ;

@prefix space: <http://example.com/space-schema/> .@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

space:mass 28801.0 .

http://.../1969-059A

http://.../Spacecraft

a

Apollo 11 Command and Service Modulename

16 July 1969launched

28801.0mass

http://.../cape+cana...

Cape Canaveral, United States name

launchsite

<http://example.com/spacecraft/1969-059A>

a space:Spacecraft ;

space:name "Apollo 11 Command and Service Module" ;

space:launched "1969-07-16"^^xsd:date ;

@prefix space: <http://example.com/space-schema/> .@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

space:launchsite <http://.../cape+cana...> .

space:mass 28801.0 . space:mass 28801.0 ;

http://.../1969-059A

http://.../Spacecraft

a

Apollo 11 Command and Service Modulename

16 July 1969launched

28801.0mass

http://.../cape+cana...

Cape Canaveral, United States name

launchsite

<http://example.com/spacecraft/1969-059A>

a space:Spacecraft ;

space:name "Apollo 11 Command and Service Module" ;

space:launched "1969-07-16"^^xsd:date ;

@prefix space: <http://example.com/space-schema/> .@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://.../cape+cana...> space:name "Cape Canaveral, United States"@en-us .

space:launchsite <http://.../cape+cana...> .

space:mass 28801.0 . space:mass 28801.0 ;

How do I SPARQL?

SPARQL

Query Language for RDFhttp://www.w3.org/TR/rdf-sparql-query

SPARQL Protocol and RDF Query Language

Graph pattern based languagewritten the same as Turtle

Several queries — Ask; Select; Describe; Construct

Read Onlystill vulnerable to injection, though not as bad as SQL

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

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 .}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Triple Patterns

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?label WHERE { ?something rdfs:label ?label .}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

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 .}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

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 .}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

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 .

}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Example QueryPREFIX 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 10OFFSET 10

Tip 1: Find all the Properties

SELECT DISTINCT ?p WHERE {

?s ?p ?o .

}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Tip 2: Find all the Classes

SELECT DISTINCT ?type WHERE {

?s a ?type .

}

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

Space Physicsspace:Discipline

space:Spacecraft

space:Launch

space:Launchsite

/discipline/spacephysics

/spacecraft/1957-001B

/launch/1957-001

/launchsite/tyurata

a

a

a

a

space:discipline

space:spacecraft

space:launchsite

Sputnik 1

The Sputnik 1 spacecraft was ...

U.S.S.R

86.3

1957-10-04

Modified SS-6 (Sapwood)

Tyuratam (Baikonur Cosmodrome)

U.S.S.R

rdfs:label

space:country

foaf:name

dc:description

space:agency

space:mass

space:launched

space:launchvehicle

rdfs:label

/images/sputnik.jpgfoaf:depiction

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.

top related