of 64 /64
Linked Data & SPARQL Birte Glimm Institut für Künstliche Intelligenz | 12. Mai 2012 Eine Einführung Foliensatz adaptiert von Andreas Harth und M. Krötzsch. Die nichtkommerzielle Vervielfältigung, Verbreitung und Bearbeitung ist zulässig ( Lizenz CC-BY-NC).

Linked Data & SPARQL - ulmapi.de · 2/51Birte Glimm j Linked Data & SPARQL j 12. Mai 2012 Agenda Resource Description Framework Linked Data SPARQL Komplexe Graph-Muster in SPARQL

Embed Size (px)

Text of Linked Data & SPARQL - ulmapi.de · 2/51Birte Glimm j Linked Data & SPARQL j 12. Mai 2012 Agenda...

  • Linked Data & SPARQLBirte GlimmInstitut fr Knstliche Intelligenz | 12. Mai 2012

    Eine Einfhrung

    Foliensatz adaptiert von Andreas Harth und M. Krtzsch. Die nichtkommerzielle Vervielfltigung,Verbreitung und Bearbeitung ist zulssig ( Lizenz CC-BY-NC).

    http://korrekt.orghttp://creativecommons.org/licenses/by-nc/3.0/deed.de

  • 2/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Agenda

    Resource Description Framework

    Linked Data

    SPARQLKomplexe Graph-Muster in SPARQLFilter in SPARQLAusgabeformate in SPARQLModifikatoren in SPARQL

  • 3/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Agenda

    Resource Description Framework

    Linked Data

    SPARQLKomplexe Graph-Muster in SPARQLFilter in SPARQLAusgabeformate in SPARQLModifikatoren in SPARQL

  • 4/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Allgemeines zu RDF

    I Resource Description FrameworkI W3C Recommendation (http://www.w3.org/RDF)I Zur Zeit in der berarbeitungI RDF ist ein Datenmodell

    I ursprnglich: zur Angabe von Metadaten frWeb-Ressourcen, spter allgemeiner

    I kodiert strukturierte InformationenI universelles, maschinenlesbares Austauschformat

  • 5/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Daten als Menge von Tripeln Graphdarstellung

    I Verschiedene syntaktische Darstellungsformen

    http://example.org/SemanticWeb http://springer.com/Verlag

    Semantic Web Grundlagen http://example.org/Verlag

    http://example.org/verlegtBei

    http://example.org/Titelhttp://www.w3.org/1999/

    02/22-rdf-syntax-ns#type

  • 6/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Agenda

    Resource Description Framework

    Linked Data

    SPARQLKomplexe Graph-Muster in SPARQLFilter in SPARQLAusgabeformate in SPARQLModifikatoren in SPARQL

  • 7/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Daten im Web

    I Immer mehr Anbieter stellen nicht nur Webseiten (HTML)im Web zur Verfgung sondern (auch) Daten

    I Dabei werden Semantic Web Standards verwendet (sieheLinking Open Data (LOD) Initiative)http://www.w3.org/wiki/SweoIG/TaskForces/CommunityProjects/LinkingOpenData

    I Verwendet werden APIs, z.B. via JSON/REST, fr denprogrammatischen Zugriff

    I Semantic Web Technologien vereinfachen die Integrationvon Daten aus verschiedenen Quellen

    I Die Kombination von Daten erlaubt tiefere Einblicke

    http://www.w3.org/wiki/SweoIG/TaskForces/CommunityProjects/LinkingOpenDatahttp://www.w3.org/wiki/SweoIG/TaskForces/CommunityProjects/LinkingOpenData

  • 8/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data im Web 01.05.2007

    Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch.http://lod-cloud.net/

    http://lod-cloud.net/

  • 9/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data im Web 31.03.2008

    SWConference

    Corpus

    DBpedia RDF Book Mashup

    DBLPBerlin

    Revyu

    Project Guten-berg

    FOAFprofiles

    Geo-names

    Music-brainz

    Magna-tuneJamendo

    World Fact-book

    DBLPHannover

    SIOCprofiles

    Sem-Web-

    Central

    Euro-stat

    ECS South-ampton

    BBCLater +TOTP

    Doap-space

    Open-Guides

    Gov-Track

    US Census Data

    W3CWordNet

    flickrwrapprWiki-

    company

    OpenCyc

    lingvoj

    Onto-world

    BBCJohnPeel

    Flickrexporter

    Audio-Scrobbler QDOS

    updated

    RKB Explorer

    NEW!riese

    NEW!

    Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch.http://lod-cloud.net/

    http://lod-cloud.net/

  • 10/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data im Web 14.07.2009

    As of July 2009

    LinkedCTReactome

    Taxonomy

    KEGG

    PubMed

    GeneID

    Pfam

    UniProt

    OMIM

    PDB

    SymbolChEBI

    Daily Med

    Disea-some

    CAS

    HGNC

    InterPro

    Drug Bank

    UniParc

    UniRef

    ProDom

    PROSITE

    Gene Ontology

    HomoloGene

    PubChem

    MGI

    UniSTS

    GEOSpecies

    Jamendo

    BBCProgrammes

    Music-brainz

    Magna-tune

    BBCLater +TOTP

    SurgeRadio

    MySpaceWrapper

    Audio-Scrobbler

    LinkedMDB

    BBCJohnPeel

    BBCPlaycount

    Data

    Gov-Track

    US Census Data

    riese

    Geo-names

    lingvoj

    World Fact-book

    Euro-stat

    flickrwrappr

    Open Calais

    RevyuSIOCSites

    Doap-space

    Flickrexporter

    FOAFprofiles

    CrunchBase

    Sem-Web-

    Central

    Open-Guides

    Wiki-company

    QDOS

    Pub Guide

    RDF ohloh

    W3CWordNet

    OpenCyc

    UMBEL

    Yago

    DBpediaFreebase

    Virtuoso Sponger

    DBLPHannover

    IRIT Toulouse

    SWConference

    Corpus

    RDF Book Mashup

    Project Guten-berg

    DBLPBerlin

    LAAS- CNRS

    Buda-pestBME

    IEEE

    IBM

    Resex

    Pisa

    New-castle

    RAE 2001

    CiteSeer

    ACM

    DBLP RKB

    Explorer

    eprints

    LIBRIS

    SemanticWeb.org

    Eurcom

    RKBECS

    South-ampton

    CORDIS

    ReSIST ProjectWiki

    NationalScience

    Foundation

    ECS South-ampton

    LinkedGeoData

    BBC Music

    Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch.http://lod-cloud.net/

    http://lod-cloud.net/

  • 11/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data im Web 22.09.2010

    As of September 2010

    MusicBrainz

    (zitgist)

    P20

    YAGO

    World Fact-book (FUB)

    WordNet (W3C)

    WordNet(VUA)

    VIVO UFVIVO

    Indiana

    VIVO Cornell

    VIAF

    URIBurner

    Sussex Reading

    Lists

    Plymouth Reading

    Lists

    UMBEL

    UK Post-codes

    legislation.gov.uk

    Uberblic

    UB Mann-heim

    TWC LOGD

    Twarql

    transportdata.gov

    .uk

    totl.net

    Tele-graphis

    TCMGeneDIT

    TaxonConcept

    The Open Library (Talis)

    t4gm

    Surge Radio

    STW

    RAMEAU SH

    statisticsdata.gov

    .uk

    St. Andrews Resource

    Lists

    ECS South-ampton EPrints

    Semantic CrunchBase

    semanticweb.org

    SemanticXBRL

    SWDog Food

    rdfabout US SEC

    Wiki

    UN/LOCODE

    Ulm

    ECS (RKB

    Explorer)

    Roma

    RISKS

    RESEX

    RAE2001

    Pisa

    OS

    OAI

    NSF

    New-castle

    LAAS

    KISTIJISC

    IRIT

    IEEE

    IBM

    Eurcom

    ERA

    ePrints

    dotAC

    DEPLOY

    DBLP (RKB

    Explorer)

    Course-ware

    CORDIS

    CiteSeer

    Budapest

    ACM

    riese

    Revyu

    researchdata.gov

    .uk

    referencedata.gov

    .uk

    Recht-spraak.

    nl

    RDFohloh

    Last.FM (rdfize)

    RDF Book

    Mashup

    PSH

    ProductDB

    PBAC

    Pok-pdia

    Ord-nance Survey

    Openly Local

    The Open Library

    OpenCyc

    OpenCalais

    OpenEI

    New York

    Times

    NTU Resource

    Lists

    NDL subjects

    MARC Codes List

    Man-chesterReading

    Lists

    Lotico

    The London Gazette

    LOIUS

    lobidResources

    lobidOrgani-sations

    LinkedMDB

    LinkedLCCN

    LinkedGeoData

    LinkedCT

    Linked Open

    Numbers

    lingvoj

    LIBRIS

    Lexvo

    LCSH

    DBLP (L3S)

    Linked Sensor Data (Kno.e.sis)

    Good-win

    Family

    Jamendo

    iServe

    NSZL Catalog

    GovTrack

    GESIS

    GeoSpecies

    GeoNames

    GeoLinkedData(es)

    GTAA

    STITCHSIDER

    Project Guten-berg (FUB)

    MediCare

    Euro-stat

    (FUB)

    DrugBank

    Disea-some

    DBLP (FU

    Berlin)

    DailyMed

    Freebase

    flickr wrappr

    Fishes of Texas

    FanHubz

    Event-Media

    EUTC Produc-

    tions

    Eurostat

    EUNIS

    ESD stan-dards

    Popula-tion (En-AKTing)

    NHS (EnAKTing)

    Mortality (En-

    AKTing)Energy

    (En-AKTing)

    CO2(En-

    AKTing)

    educationdata.gov

    .uk

    ECS South-ampton

    Gem. Norm-datei

    datadcs

    MySpace(DBTune)

    MusicBrainz

    (DBTune)

    Magna-tune

    John Peel(DB

    Tune)

    classical(DB

    Tune)

    Audio-scrobbler (DBTune)

    Last.fmArtists

    (DBTune)

    DBTropes

    dbpedia lite

    DBpedia

    Pokedex

    Airports

    NASA (Data Incu-bator)

    MusicBrainz(Data

    Incubator)

    Moseley Folk

    Discogs(Data In-cubator)

    Climbing

    Linked Data for Intervals

    Cornetto

    Chronic-ling

    America

    Chem2Bio2RDF

    biz.data.

    gov.uk

    UniSTS

    UniRef

    UniPath-way

    UniParc

    Taxo-nomy

    UniProt

    SGD

    Reactome

    PubMed

    PubChem

    PRO-SITE

    ProDom

    Pfam PDB

    OMIM

    OBO

    MGI

    KEGG Reaction

    KEGG Pathway

    KEGG Glycan

    KEGG Enzyme

    KEGG Drug

    KEGG Cpd

    InterPro

    HomoloGene

    HGNC

    Gene Ontology

    GeneID

    GenBank

    ChEBI

    CAS

    Affy-metrix

    BibBaseBBC

    Wildlife Finder

    BBC Program

    mesBBC

    Music

    rdfaboutUS Census

    Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch.http://lod-cloud.net/

    http://lod-cloud.net/

  • 12/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data im Web 19.09.2011

    As of September 2011

    MusicBrainz

    (zitgist)

    P20

    Turismo de

    Zaragoza

    yovisto

    Yahoo! Geo

    Planet

    YAGO

    World Fact-book

    El ViajeroTourism

    WordNet (W3C)

    WordNet (VUA)

    VIVO UF

    VIVO Indiana

    VIVO Cornell

    VIAF

    URIBurner

    Sussex Reading

    Lists

    Plymouth Reading

    Lists

    UniRef

    UniProt

    UMBEL

    UK Post-codes

    legislationdata.gov.uk

    Uberblic

    UB Mann-heim

    TWC LOGD

    Twarql

    transportdata.gov.

    uk

    Traffic Scotland

    theses.fr

    Thesau-rus W

    totl.net

    Tele-graphis

    TCMGeneDIT

    TaxonConcept

    Open Library (Talis)

    tags2con delicious

    t4gminfo

    Swedish Open

    Cultural Heritage

    Surge Radio

    Sudoc

    STW

    RAMEAU SH

    statisticsdata.gov.

    uk

    St. Andrews Resource

    Lists

    ECS South-ampton EPrints

    SSW Thesaur

    us

    SmartLink

    Slideshare2RDF

    semanticweb.org

    SemanticTweet

    Semantic XBRL

    SWDog Food

    Source Code Ecosystem Linked Data

    US SEC (rdfabout)

    Sears

    Scotland Geo-

    graphy

    ScotlandPupils &Exams

    Scholaro-meter

    WordNet (RKB

    Explorer)

    Wiki

    UN/LOCODE

    Ulm

    ECS (RKB

    Explorer)

    Roma

    RISKS

    RESEX

    RAE2001

    Pisa

    OS

    OAI

    NSF

    New-castle

    LAASKISTI

    JISC

    IRIT

    IEEE

    IBM

    Eurcom

    ERA

    ePrints dotAC

    DEPLOY

    DBLP (RKB

    Explorer)

    Crime Reports

    UK

    Course-ware

    CORDIS (RKB

    Explorer)CiteSeer

    Budapest

    ACM

    riese

    Revyu

    researchdata.gov.

    ukRen. Energy Genera-

    tors

    referencedata.gov.

    uk

    Recht-spraak.

    nl

    RDFohloh

    Last.FM (rdfize)

    RDF Book

    Mashup

    Rdata n!

    PSH

    Product Types

    Ontology

    ProductDB

    PBAC

    Pok-pdia

    patentsdata.go

    v.uk

    OxPoints

    Ord-nance Survey

    Openly Local

    Open Library

    OpenCyc

    Open Corpo-rates

    OpenCalais

    OpenEI

    Open Election

    Data Project

    OpenData

    Thesau-rus

    Ontos News Portal

    OGOLOD

    JanusAMP

    Ocean Drilling Codices

    New York

    Times

    NVD

    ntnusc

    NTU Resource

    Lists

    Norwe-gian

    MeSH

    NDL subjects

    ndlna

    myExperi-ment

    Italian Museums

    medu-cator

    MARC Codes List

    Man-chester Reading

    Lists

    Lotico

    Weather Stations

    London Gazette

    LOIUS

    Linked Open Colors

    lobidResources

    lobidOrgani-sations

    LEM

    LinkedMDB

    LinkedLCCN

    LinkedGeoData

    LinkedCT

    LinkedUser

    FeedbackLOV

    Linked Open

    Numbers

    LODE

    Eurostat (OntologyCentral)

    Linked EDGAR

    (OntologyCentral)

    Linked Crunch-

    base

    lingvoj

    Lichfield Spen-ding

    LIBRIS

    Lexvo

    LCSH

    DBLP (L3S)

    Linked Sensor Data (Kno.e.sis)

    Klapp-stuhl-club

    Good-win

    Family

    National Radio-activity

    JP

    Jamendo (DBtune)

    Italian public

    schools

    ISTAT Immi-gration

    iServe

    IdRef Sudoc

    NSZL Catalog

    Hellenic PD

    Hellenic FBD

    PiedmontAccomo-dations

    GovTrack

    GovWILD

    GoogleArt

    wrapper

    gnoss

    GESIS

    GeoWordNet

    GeoSpecies

    GeoNames

    GeoLinkedData

    GEMET

    GTAA

    STITCH

    SIDER

    Project Guten-berg

    MediCare

    Euro-stat

    (FUB)

    EURES

    DrugBank

    Disea-some

    DBLP (FU

    Berlin)

    DailyMed

    CORDIS(FUB)

    Freebase

    flickr wrappr

    Fishes of Texas

    Finnish Munici-palities

    ChEMBL

    FanHubz

    EventMedia

    EUTC Produc-

    tions

    Eurostat

    Europeana

    EUNIS

    EU Insti-

    tutions

    ESD stan-dards

    EARTh

    Enipedia

    Popula-tion (En-AKTing)

    NHS(En-

    AKTing) Mortality(En-

    AKTing)

    Energy (En-

    AKTing)

    Crime(En-

    AKTing)

    CO2 Emission

    (En-AKTing)

    EEA

    SISVU

    education.data.g

    ov.uk

    ECS South-ampton

    ECCO-TCP

    GND

    Didactalia

    DDC Deutsche Bio-

    graphie

    datadcs

    MusicBrainz

    (DBTune)

    Magna-tune

    John Peel

    (DBTune)

    Classical (DB

    Tune)

    AudioScrobbler (DBTune)

    Last.FM artists

    (DBTune)

    DBTropes

    Portu-guese

    DBpedia

    dbpedia lite

    Greek DBpedia

    DBpedia

    data-open-ac-uk

    SMCJournals

    Pokedex

    Airports

    NASA (Data Incu-bator)

    MusicBrainz(Data

    Incubator)

    Moseley Folk

    Metoffice Weather Forecasts

    Discogs (Data

    Incubator)

    Climbing

    data.gov.uk intervals

    Data Gov.ie

    databnf.fr

    Cornetto

    reegle

    Chronic-ling

    America

    Chem2Bio2RDF

    Calames

    businessdata.gov.

    uk

    Bricklink

    Brazilian Poli-

    ticians

    BNB

    UniSTS

    UniPathway

    UniParc

    Taxonomy

    UniProt(Bio2RDF)

    SGD

    Reactome

    PubMedPub

    Chem

    PRO-SITE

    ProDom

    Pfam

    PDB

    OMIMMGI

    KEGG Reaction

    KEGG Pathway

    KEGG Glycan

    KEGG Enzyme

    KEGG Drug

    KEGG Com-pound

    InterPro

    HomoloGene

    HGNC

    Gene Ontology

    GeneID

    Affy-metrix

    bible ontology

    BibBase

    FTS

    BBC Wildlife Finder

    BBC Program

    mes BBC Music

    Alpine Ski

    Austria

    LOCAH

    Amster-dam

    Museum

    AGROVOC

    AEMET

    US Census (rdfabout)

    Linking Open Data cloud diagram, by Richard Cyganiak and Anja Jentzsch.http://lod-cloud.net/

    http://lod-cloud.net/

  • 13/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Semantic Web Technologien

    I Ntzlich zum Publizieren, zum Austausch und zurIntegration von Daten

    I Semantic Web Technologien sind mittlerweile rechtausgereift

    I IRIs (IETF RFC 3987, 2005)I HTTP (IETF RFC 2616, 1999)I RDF (W3C Recommendation, 1999, Update in 2004)I RDFS (W3C Recommendation, 2004)I SPARQL (W3C Recommendation, 2008, Update im

    Moment)I OWL (W3C Recommendation, 2004, Update in 2009)

    I Linked Data besteht aus einigen Prinzipien zumPublizieren von Daten im Web

  • 14/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data Principles*

    1. Use URIs to name things; not only documents, but alsopeople, locations, concepts, etc.

    2. To enable agents (human users and machine agents alike)to look up those names, use HTTP URIs

    3. When someone looks up a URI we provide usefulinformation; with useful in the strict sense we usuallymean structured data in RDF.

    4. Include links to other URIs allowing agents (machines andhumans) to discover more things

    *http://www.w3.org/DesignIssues/LinkedData.html

    http://www.w3.org/DesignIssues/LinkedData.html

  • 15/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Zusammenhang zwischen URI einer Sacheund URI einer Quelle

    User Agent

    Web Server

    http://www.polleres.net/foaf.rdf#me

    http://www.polleres.net/foaf.rdf

    HTTPGET

    RDF

  • 16/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Zusammenhang zwischen URI einer Sacheund URI einer Quelle

    User Agent

    Web Server

    http://dbpedia.org/resource/Gordon_Brown

    http://dbpedia.org/data/Gordon_Brown

    http://dbpedia.org/page/Gordon_Brown

    HTTPGET

    303*HTTPGET

    RDF

    *HTTP Response Code 303: See Other

  • 17/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Hintergrund: Uniform Resource Identifiers

    I Ein Uniform Resource Identifier ist eine kompakteSequenz von Charakteren, die eine abstrakte oderphysikalische Ressource identifizieren [RFC3986]

    I SyntaxURI = Schema ":" [ Anbieter ] Pfad [ "?" Abfrage ] [ "#" Teil ]

    I Beispiel

    foo:// Schema

    Anbieter example.com:8042/ bar

    Pfad

    Abfrage ?name=peter#titel

    Teil

  • 18/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    URIs/IRIsProtokoll http://

    Domne semanticweb.org/id/

    Namensraum

    Axel_Polleres Lokaler Name

    Prfix thing:

    Axel_Polleres

    I URIs sind Uniform Resource IdentifiersI IRIs sind Unicode-basierte Internationalized Resource

    IdentifiersI Jede URI identifiziert eine EntittI Semantic Web URIs nutzen blicherweise HTTP

    I HyperText Transfer ProtocolI Knnen idealerweise aufgelst werden, um weitere Daten

    zu erhaltenI Linked Data

  • 19/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    HTTP bersicht

    I HTTP Nachrichten bestehen aus der Anfrage eines Clientsan einen Server und die Antworten des Servers zum Client

    I Bestimmte Methoden sind vordefiniert (z.B. GET, POST,etc.), aber weitere knnen definiert werden

    I Eine Menge von Statuscodes ist definiert:I Informational 1xx, provisional response, (100 Continue)I Successful 2xx, request successfully received, understood,

    and accepted (201 Created)I Redirection 3xx, further action needs to be taken by user

    agent to fulfill the request (301 Moved Permanently)I Client Error 4xx, client erred (405 Method Not Allowed)I Server Error 5xx, server encountered an unexpected

    condition (501 Not Implemented)

  • 20/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    HTTP Content Negotiation

    I Content Negotiation (CN, conneg) ist der Prozess derSelektion der besten Reprsentation fr eine Anfragewenn mehrere Reprsentationen verfgbar sind

    I Drei Arten: server-driven, agent-driven, transparent

    $ curl -H "Accept: application/rdf+xml"http://dbpedia.org/resource/Galway

    HTTP/1.1 303 See OtherContent-Type: application/rdf+xmlLocation: http://dbpedia.org/data/Galway.rdf$

    curl Tool um Daten zu einem Server zu schicken oder von einemServer zu empfangen-H bedeutet nur HTTP/HTTPS

  • 21/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Semantic Web Application Architecture

  • 21/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Semantic Web Application Architecture

  • 22/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Linked Data Anwendungen: Minimale Architektur

    As of September 2011

    MusicBrainz

    (zitgist)

    P20

    Turismo de

    Zaragoza

    yovisto

    Yahoo! Geo

    Planet

    YAGO

    World Fact-book

    El ViajeroTourism

    WordNet (W3C)

    WordNet (VUA)

    VIVO UF

    VIVO Indiana

    VIVO Cornell

    VIAF

    URIBurner

    Sussex Reading

    Lists

    Plymouth Reading

    Lists

    UniRef

    UniProt

    UMBEL

    UK Post-codes

    legislationdata.gov.uk

    Uberblic

    UB Mann-heim

    TWC LOGD

    Twarql

    transportdata.gov.

    uk

    Traffic Scotland

    theses.fr

    Thesau-rus W

    totl.net

    Tele-graphis

    TCMGeneDIT

    TaxonConcept

    Open Library (Talis)

    tags2con delicious

    t4gminfo

    Swedish Open

    Cultural Heritage

    Surge Radio

    Sudoc

    STW

    RAMEAU SH

    statisticsdata.gov.

    uk

    St. Andrews Resource

    Lists

    ECS South-ampton EPrints

    SSW Thesaur

    us

    SmartLink

    Slideshare2RDF

    semanticweb.org

    SemanticTweet

    Semantic XBRL

    SWDog Food

    Source Code Ecosystem Linked Data

    US SEC (rdfabout)

    Sears

    Scotland Geo-

    graphy

    ScotlandPupils &Exams

    Scholaro-meter

    WordNet (RKB

    Explorer)

    Wiki

    UN/LOCODE

    Ulm

    ECS (RKB

    Explorer)

    Roma

    RISKS

    RESEX

    RAE2001

    Pisa

    OS

    OAI

    NSF

    New-castle

    LAASKISTI

    JISC

    IRIT

    IEEE

    IBM

    Eurcom

    ERA

    ePrints dotAC

    DEPLOY

    DBLP (RKB

    Explorer)

    Crime Reports

    UK

    Course-ware

    CORDIS (RKB

    Explorer)CiteSeer

    Budapest

    ACM

    riese

    Revyu

    researchdata.gov.

    ukRen. Energy Genera-

    tors

    referencedata.gov.

    uk

    Recht-spraak.

    nl

    RDFohloh

    Last.FM (rdfize)

    RDF Book

    Mashup

    Rdata n!

    PSH

    Product Types

    Ontology

    ProductDB

    PBAC

    Pok-pdia

    patentsdata.go

    v.uk

    OxPoints

    Ord-nance Survey

    Openly Local

    Open Library

    OpenCyc

    Open Corpo-rates

    OpenCalais

    OpenEI

    Open Election

    Data Project

    OpenData

    Thesau-rus

    Ontos News Portal

    OGOLOD

    JanusAMP

    Ocean Drilling Codices

    New York

    Times

    NVD

    ntnusc

    NTU Resource

    Lists

    Norwe-gian

    MeSH

    NDL subjects

    ndlna

    myExperi-ment

    Italian Museums

    medu-cator

    MARC Codes List

    Man-chester Reading

    Lists

    Lotico

    Weather Stations

    London Gazette

    LOIUS

    Linked Open Colors

    lobidResources

    lobidOrgani-sations

    LEM

    LinkedMDB

    LinkedLCCN

    LinkedGeoData

    LinkedCT

    LinkedUser

    FeedbackLOV

    Linked Open

    Numbers

    LODE

    Eurostat (OntologyCentral)

    Linked EDGAR

    (OntologyCentral)

    Linked Crunch-

    base

    lingvoj

    Lichfield Spen-ding

    LIBRIS

    Lexvo

    LCSH

    DBLP (L3S)

    Linked Sensor Data (Kno.e.sis)

    Klapp-stuhl-club

    Good-win

    Family

    National Radio-activity

    JP

    Jamendo (DBtune)

    Italian public

    schools

    ISTAT Immi-gration

    iServe

    IdRef Sudoc

    NSZL Catalog

    Hellenic PD

    Hellenic FBD

    PiedmontAccomo-dations

    GovTrack

    GovWILD

    GoogleArt

    wrapper

    gnoss

    GESIS

    GeoWordNet

    GeoSpecies

    GeoNames

    GeoLinkedData

    GEMET

    GTAA

    STITCH

    SIDER

    Project Guten-berg

    MediCare

    Euro-stat

    (FUB)

    EURES

    DrugBank

    Disea-some

    DBLP (FU

    Berlin)

    DailyMed

    CORDIS(FUB)

    Freebase

    flickr wrappr

    Fishes of Texas

    Finnish Munici-palities

    ChEMBL

    FanHubz

    EventMedia

    EUTC Produc-

    tions

    Eurostat

    Europeana

    EUNIS

    EU Insti-

    tutions

    ESD stan-dards

    EARTh

    Enipedia

    Popula-tion (En-AKTing)

    NHS(En-

    AKTing) Mortality(En-

    AKTing)

    Energy (En-

    AKTing)

    Crime(En-

    AKTing)

    CO2 Emission

    (En-AKTing)

    EEA

    SISVU

    education.data.g

    ov.uk

    ECS South-ampton

    ECCO-TCP

    GND

    Didactalia

    DDC Deutsche Bio-

    graphie

    datadcs

    MusicBrainz

    (DBTune)

    Magna-tune

    John Peel

    (DBTune)

    Classical (DB

    Tune)

    AudioScrobbler (DBTune)

    Last.FM artists

    (DBTune)

    DBTropes

    Portu-guese

    DBpedia

    dbpedia lite

    Greek DBpedia

    DBpedia

    data-open-ac-uk

    SMCJournals

    Pokedex

    Airports

    NASA (Data Incu-bator)

    MusicBrainz(Data

    Incubator)

    Moseley Folk

    Metoffice Weather Forecasts

    Discogs (Data

    Incubator)

    Climbing

    data.gov.uk intervals

    Data Gov.ie

    databnf.fr

    Cornetto

    reegle

    Chronic-ling

    America

    Chem2Bio2RDF

    Calames

    businessdata.gov.

    uk

    Bricklink

    Brazilian Poli-

    ticians

    BNB

    UniSTS

    UniPathway

    UniParc

    Taxonomy

    UniProt(Bio2RDF)

    SGD

    Reactome

    PubMedPub

    Chem

    PRO-SITE

    ProDom

    Pfam

    PDB

    OMIMMGI

    KEGG Reaction

    KEGG Pathway

    KEGG Glycan

    KEGG Enzyme

    KEGG Drug

    KEGG Com-pound

    InterPro

    HomoloGene

    HGNC

    Gene Ontology

    GeneID

    Affy-metrix

    bible ontology

    BibBase

    FTS

    BBC Wildlife Finder

    BBC Program

    mes BBC Music

    Alpine Ski

    Austria

    LOCAH

    Amster-dam

    Museum

    AGROVOC

    AEMET

    US Census (rdfabout)

    Abf

    rage

    Ant

    wor

    t

  • 23/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Szenario

    I Typisches Datenintegrationsszenario

    Gemeinsames

    Datenformat

    Daten

    Integration

    Interaktive

    Datenexploration

    I Anfrage: Welche Jobangebote gibt es von Konkurrentenvon Facebook?

  • 24/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Agenda

    Resource Description Framework

    Linked Data

    SPARQLKomplexe Graph-Muster in SPARQLFilter in SPARQLAusgabeformate in SPARQLModifikatoren in SPARQL

  • 25/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    SPARQL

    SPARQL (sprich engl. sparkle) steht frSPARQL Protocol And RDF Query LanguageI W3C Spezifikation seit 2008I Zur Zeit Erweiterung auf SPARQL 1.1I Anfragsprache zur Abfrage von Instanzen aus

    RDF-DokumentenI Groe praktische Bedeutung

    Teile der SPARQL 1.0 SpezifikationI Anfragesprache: Thema dieser VorlesungI Ergebnisformat: Darstellung von Ergebnissen in XMLI Anfrageprotokoll: bermittlung von Anfragen und

    Ergebnissen

  • 26/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Teile der SPARQL 1.1 Spezifikation

    I Query: Erweitert die Sprachkonstrukte fr SPARQLAbfragen

    I Update: zur Modifikation von RDF Graphen (Hinzufgen,Lschen)

    I Graph Store HTTP Protocol: HTTP Operationen um eineMenge von Graphen zu verwalten

    I Entailment Regimes: Abfragen auch von implizitenKonsequenzen

    I Service Description: Methode zum Beschreiben vonSPARQL Endpunkten

    I Federation Extensions: Ausfhrung von verteilten AbfragenI Query Results JSON Format: Abfrageergebnisse in JSONI Query Results CSV, TSV Format: Komma und Tab

    separierte Abfrageergebnisse

  • 27/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Anfragen

    Eine einfache Beispielanfrage:PREFIX foaf: SELECT ?name ?mboxWHERE { ?x foaf:name ?name .

    ?x foaf:mbox ?mbox }

    I Die Bedingung der WHERE Klausel heisst querypattern/Abfragemuster

    I Tripel mit Variablen heissen basic graph pattern (BGP)

    BGPs verwenden Turtle Syntax fr RDF BGPs knnen Variablen (?variable oder $variable)

    enthalten

    I Abgekrzte IRIs sind mglich (PREFIX)I Abfrageergebnis fr die selektierten Variablen (SELECT)

  • 27/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Anfragen

    Eine einfache Beispielanfrage:PREFIX foaf: SELECT ?name ?mboxWHERE { ?x foaf:name ?name .

    ?x foaf:mbox ?mbox }

    I Die Bedingung der WHERE Klausel heisst querypattern/Abfragemuster

    I Tripel mit Variablen heissen basic graph pattern (BGP)

    BGPs verwenden Turtle Syntax fr RDF BGPs knnen Variablen (?variable oder $variable)

    enthalten

    I Abgekrzte IRIs sind mglich (PREFIX)I Abfrageergebnis fr die selektierten Variablen (SELECT)

  • 27/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Anfragen

    Eine einfache Beispielanfrage:PREFIX foaf: SELECT ?name ?mboxWHERE { ?x foaf:name ?name .

    ?x foaf:mbox ?mbox }

    I Die Bedingung der WHERE Klausel heisst querypattern/Abfragemuster

    I Tripel mit Variablen heissen basic graph pattern (BGP) BGPs verwenden Turtle Syntax fr RDF BGPs knnen Variablen (?variable oder $variable)

    enthalten

    I Abgekrzte IRIs sind mglich (PREFIX)I Abfrageergebnis fr die selektierten Variablen (SELECT)

  • 27/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Anfragen

    Eine einfache Beispielanfrage:PREFIX foaf: SELECT ?name ?mboxWHERE { ?x foaf:name ?name .

    ?x foaf:mbox ?mbox }

    I Die Bedingung der WHERE Klausel heisst querypattern/Abfragemuster

    I Tripel mit Variablen heissen basic graph pattern (BGP) BGPs verwenden Turtle Syntax fr RDF BGPs knnen Variablen (?variable oder $variable)

    enthaltenI Abgekrzte IRIs sind mglich (PREFIX)

    I Abfrageergebnis fr die selektierten Variablen (SELECT)

  • 27/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Anfragen

    Eine einfache Beispielanfrage:PREFIX foaf: SELECT ?name ?mboxWHERE { ?x foaf:name ?name .

    ?x foaf:mbox ?mbox }

    I Die Bedingung der WHERE Klausel heisst querypattern/Abfragemuster

    I Tripel mit Variablen heissen basic graph pattern (BGP) BGPs verwenden Turtle Syntax fr RDF BGPs knnen Variablen (?variable oder $variable)

    enthaltenI Abgekrzte IRIs sind mglich (PREFIX)I Abfrageergebnis fr die selektierten Variablen (SELECT)

  • 28/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    BeispielergebnisBGP: {?x foaf:name ?name. ?x foaf:mbox ?mbox}

    @prefix foaf: http://xmlns.com/foaf/0.1/ ._:a foaf:name "Birte Glimm" ;

    foaf:mbox "[email protected]" ;foaf:icqChatID "b.glimm" ;foaf:aimChatID "b.glimm" .

    _:b foaf:name "Sebastian Rudolph" ;foaf:mbox .

    _:c foaf:name "Pascal Hitzler" ;foaf:aimChatID "phi" .

    foaf:icqChatID rdfs:subPropertyOf foaf:nick .foaf:name rdfs:domain foaf:Person .

    BGP Matching Ergebnis (Tabelle mit einer Zeile je Ergebnis):x name mbox

    _ :a "Birte Glimm" "[email protected]"_ :b "Sebastian Rudolph"

  • 29/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Beispielergebnis

    PREFIX foaf: SELECT ?name ?mboxWHERE { ?x foaf:name ?name .

    ?x foaf:mbox ?mbox }

    BGP Matching Ergebnis:x name mbox

    _ :a "Birte Glimm" "[email protected]"_ :b "Sebastian Rudolph"

    Abfrageergebnis:name mbox

    "Birte Glimm" "[email protected]""Sebastian Rudolph"

  • 30/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Graph-Muster

    Die grundlegenden Anfragemuster sind einfache Graph-Musteroder basic graph patterns (BGPs)I Menge von RDF-Tripeln in Turtle-SyntaxI Turtle-Abkrzungen (mittels , und ;) zulssigI Variablen werden durch ? oder $ gekennzeichnet

    (?variable hat gleiche Bedeutung wie $variable)I Variablen zulssig als Subjekt, Prdikat oder Objekt

    Zulssig 6= lesbar:PREFIX foaf: SELECT ?rf456df ?ac66sBWHERE { ?h4dF8Q foaf:name ?rf456df .

    ?h4dF8Q foaf:mbox ?ac66sB }

    (semantisch quivalent zur vorherigen Anfrage)

  • 30/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Einfache Graph-Muster

    Die grundlegenden Anfragemuster sind einfache Graph-Musteroder basic graph patterns (BGPs)I Menge von RDF-Tripeln in Turtle-SyntaxI Turtle-Abkrzungen (mittels , und ;) zulssigI Variablen werden durch ? oder $ gekennzeichnet

    (?variable hat gleiche Bedeutung wie $variable)I Variablen zulssig als Subjekt, Prdikat oder Objekt

    Zulssig 6= lesbar:PREFIX foaf: SELECT ?rf456df ?ac66sBWHERE { ?h4dF8Q foaf:name ?rf456df .

    ?h4dF8Q foaf:mbox ?ac66sB }

    (semantisch quivalent zur vorherigen Anfrage)

  • 31/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Was bedeuten leere Knoten in SPARQL?

    Leere Knoten in Anfragemustern:I Zulssig als Subjekt oder ObjektI ID beliebig, aber niemals gleiche ID mehrfach pro AnfrageI Verhalten sich wie Variablen, die nicht ausgewhlt werden

    knnen

    Leere Knoten in Ergebnissen:I Platzhalter fr unbekannte ElementeI IDs beliebig, aber eventuell an andere Ergebnisteile

    gebunden:subj Wert_:a "zum"_:b "Beispiel"

    subj Wert_:y "zum"_:g "Beispiel"

    subj Wert_:z "zum"_:z "Beispiel"

  • 31/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Was bedeuten leere Knoten in SPARQL?

    Leere Knoten in Anfragemustern:I Zulssig als Subjekt oder ObjektI ID beliebig, aber niemals gleiche ID mehrfach pro AnfrageI Verhalten sich wie Variablen, die nicht ausgewhlt werden

    knnenLeere Knoten in Ergebnissen:I Platzhalter fr unbekannte ElementeI IDs beliebig, aber eventuell an andere Ergebnisteile

    gebunden:subj Wert_:a "zum"_:b "Beispiel"

    subj Wert_:y "zum"_:g "Beispiel"

    subj Wert_:z "zum"_:z "Beispiel"

  • 32/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Datasets und FROM (NAMED)

    I Keine FROM Klausel notwendugI Jeder SPARQL Service spezifiziert ein Dataset bestehend

    aus einem Default Graphen und keinem oder mehrbenannten Graphen (named graphs)

    Keine FROM Klausel Auswertung bzgl. des Default GraphenFROM NAMED in Kombination mit dem GRAPH Schlsselwort Auswertung ber den benannten GraphenFROM Klausel Erzeugung eines neuen Default Graphen fr die Abfrage

    SELECT ?name ?mboxFROM NAMED WHERE { GRAPH ?g

    { ?x foaf:name ?name. ?x foaf:mbox ?mbox }}

  • 33/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    [email protected] xsd: [email protected]ix ex: .ex:ex1 ex:p "test" .ex:ex2 ex:p "test"^^xsd:string .ex:ex3 ex:p "test"@en .ex:ex4 ex:p "42"^^xsd:integer .

    Was liefert eine Anfrage mit folgendem Muster?{ ?subject "test" . }

    ex:ex1 als einziges Ergebnis genaue bereinstimmung der Datentypen gefordert

    Aber: Abkrzung fr Zahlenwerte mglich{ ?subject 42 . }

    Datentyp wird aus syntaktischer Form bestimmt:xsd:integer (42), xsd:decimal (42.2), xsd:double (1.0e6)

  • 33/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    [email protected] xsd: [email protected] ex: .ex:ex1 ex:p "test" .ex:ex2 ex:p "test"^^xsd:string .ex:ex3 ex:p "test"@en .ex:ex4 ex:p "42"^^xsd:integer .

    Was liefert eine Anfrage mit folgendem Muster?{ ?subject "test" . }

    ex:ex1 als einziges Ergebnis genaue bereinstimmung der Datentypen gefordert

    Aber: Abkrzung fr Zahlenwerte mglich{ ?subject 42 . }

    Datentyp wird aus syntaktischer Form bestimmt:xsd:integer (42), xsd:decimal (42.2), xsd:double (1.0e6)

  • 34/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Gruppierende Graph-Muster

    Einfache Graph-Muster knnen durch {. . . } gruppiert werden.

    Beispiel:

    PREFIX ex: SELECT ?titel ?authorWHERE{ { ?buch ex:publishedBy .

    ?buch ex:Titel ?titel . }{ }?buch ex:Author ?author .

    }

    Sinnvoll erst bei Verwendung zustzlicher Konstruktoren

  • 35/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Optionale Muster

    Das Schlsselwort OPTIONAL erlaubt die Angabe optionalerTeile eines Musters.

    Beispiel:

    { ?book ex:publishedBy .OPTIONAL { ?book ex:Titel ?titel . }OPTIONAL { ?book ex:Author ?author . }

    }

    Teile eines Anfrageergebnisses knnen ungebunden sein:

    book titel author "Titel1" "Titel2" "Titel3" _:a _:a

  • 35/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Optionale Muster

    Das Schlsselwort OPTIONAL erlaubt die Angabe optionalerTeile eines Musters.

    Beispiel:

    { ?book ex:publishedBy .OPTIONAL { ?book ex:Titel ?titel . }OPTIONAL { ?book ex:Author ?author . }

    }

    Teile eines Anfrageergebnisses knnen ungebunden sein:

    book titel author "Titel1" "Titel2" "Titel3" _:a _:a

  • 36/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Alternative Muster

    Das Schlsselwort UNION erlaubt die Angabe alternativer Teileeines Musters.

    Example:

    { ?book ex:publishedBy .{ ?book ex:Author ?author . } UNION{ ?book ex:Editor ?author . }

    }

    Ergebnis entspricht Vereinigung der Ergebnisse mit einerder beiden Bedingungen

    Anm.: Gleiche Variablennamen in beiden Teilen von UNIONbeeinflussen sich nicht

  • 37/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Kombination von Optionen und Alternativen (1)Wie sind Kombinationen von OPTIONAL und UNION zuverstehen?{ ?book ex:publishedBy .

    { ?book ex:Author ?author . } UNION{ ?book ex:Editor ?author . } OPTIONAL{ ?author ex:Surname ?name . } }

    I Vereinigung zweier Muster mit angefgtem optionalemMuster oder

    I Vereinigung zweier Muster, wobei das zweite einenoptionalen Teil hat?

    Erste Interpretation korrekt:{ ?book ex:publishedBy .

    { { ?book ex:Author ?author . } UNION{ ?book ex:Editor ?author . }

    } OPTIONAL { ?author ex:Surname ?name . } }

  • 37/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Kombination von Optionen und Alternativen (1)Wie sind Kombinationen von OPTIONAL und UNION zuverstehen?{ ?book ex:publishedBy .

    { ?book ex:Author ?author . } UNION{ ?book ex:Editor ?author . } OPTIONAL{ ?author ex:Surname ?name . } }

    I Vereinigung zweier Muster mit angefgtem optionalemMuster oder

    I Vereinigung zweier Muster, wobei das zweite einenoptionalen Teil hat?

    Erste Interpretation korrekt:{ ?book ex:publishedBy .

    { { ?book ex:Author ?author . } UNION{ ?book ex:Editor ?author . }

    } OPTIONAL { ?author ex:Surname ?name . } }

  • 38/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Kombination von Optionen und Alternativen (2)

    Allgemeine RegelnI OPTIONAL bezieht sich immer auf genau ein

    gruppierendes Muster rechts davon.I OPTIONAL und UNION sind gleichwertig und beziehen sich

    auf jeweils alle links davon stehenden Ausdrcke(linksassoziativ)

  • 39/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Wozu Filter?

    Viele Anfragen sind auch mit komplexen Graph-Mustern nichtmglich:I Welche Personen sind zwischen 18 und 23 Jahre alt?I Der Nachname welcher Personen enthlt einen

    Bindestrich?I Welche Texte in deutscher Sprache sind in der Ontologie

    angegeben? Filter als allgemeiner Mechanismus fr solche

    Ausdrucksmittel

  • 40/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Filter in SPARQLBeispiel:

    PREFIX ex: SELECT ?book WHERE

    { ?book ex:publishedBy .?book ex:Price ?priceFILTER (?price < 35)

    }

    I Schlsselwort FILTER, gefolgt von Filterausdruck inKlammern

    I Filterbedingungen liefern Wahrheitswerte (und ev. auchFehler)

    I Viele Filterfunktionen nicht durch RDF spezifiziert Funktionen teils aus XQuery/XPath-Standard fr XMLbernommen

  • 41/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Filterfunktionen: Vergleiche und Arithmetik

    Vergleichoperatoren: , =, !=I Vergleich von Datenliteralen gem der jeweils natrlichen

    ReihenfolgeI Untersttzung fr numerische Datentypen,xsd:dateTime, xsd:string (alphabetische Ordnung),xsd:Boolean (1 > 0)

    I fr andere Typen und sonstige RDF-Elemente nur = und!= verfgbar

    I kein Vergleich von Literalen inkompatibler Typen (z.B.xsd:string und xsd:integer)

    Arithmetische Operatoren: +, -, *, /I Untersttzung fr numerische DatentypenI Verwendung zur Kombination von Werten in

    FilterbedingungenBsp.: FILTER( ?gewicht/(?groesse * ?groesse) >= 25 )

  • 41/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Filterfunktionen: Vergleiche und Arithmetik

    Vergleichoperatoren: , =, !=I Vergleich von Datenliteralen gem der jeweils natrlichen

    ReihenfolgeI Untersttzung fr numerische Datentypen,xsd:dateTime, xsd:string (alphabetische Ordnung),xsd:Boolean (1 > 0)

    I fr andere Typen und sonstige RDF-Elemente nur = und!= verfgbar

    I kein Vergleich von Literalen inkompatibler Typen (z.B.xsd:string und xsd:integer)

    Arithmetische Operatoren: +, -, *, /I Untersttzung fr numerische DatentypenI Verwendung zur Kombination von Werten in

    FilterbedingungenBsp.: FILTER( ?gewicht/(?groesse * ?groesse) >= 25 )

  • 42/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Filterfunktionen: Spezialfunktionen fr RDF

    SPARQL untersttzt auch RDF-spezifische Filterfunktionen:

    BOUND(A) true falls A eine gebundene Variable istisURI(A) true falls A eine URI istisBLANK(A) true falls A ein leerer Knoten istisLITERAL(A) true falls A ein RDF-Literal istSTR(A) lexikalische Darstellung (xsd:string) von

    RDF-Literalen oder URIsLANG(A) Sprachcode eines RDF-Literals (xsd:string)

    oder leerer String falls kein SprachcodeDATATYPE(A) Datentyp-URI eines RDF-Literals

    (xsd:string bei ungetypten Literalen ohneSprachangabe)

  • 43/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Ausgabeformatierung mit SELECT

    Bisher waren alle Ergebnisse Tabellen: Ausgabeformat SELECT

    Syntax: SELECT oder SELECT *

    VorteilEinfache sequentielle Abarbeitung von Ergebnissen

    NachteilStruktur/Beziehungen der Objekte im Ergebnis nichtoffensichtlich

  • 44/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Ausgabeformatierung mit CONSTRUCT

    Kodierung von Ergebnissen in RDF-Graphen: AusgabeformatCONSTRUCT

    Syntax: CONSTRUCT PREFIX ex: CONSTRUCT { ?person ex:mailbox ?email .

    ?person ex:telefon ?telefon . }WHERE { ?person ex:email ?email .

    ?person ex:tel ?telefon . }

    VorteilStukturiertes Ergebnis mit Beziehungen zwischen Elementen

    NachteileI Sequentielle Abarbeitung von Ergebnissen erschwertI Keine Behandlung von ungebundenen Variablen

  • 44/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Ausgabeformatierung mit CONSTRUCT

    Kodierung von Ergebnissen in RDF-Graphen: AusgabeformatCONSTRUCT

    Syntax: CONSTRUCT PREFIX ex: CONSTRUCT { ?person ex:mailbox ?email .

    ?person ex:telefon ?telefon . }WHERE { ?person ex:email ?email .

    ?person ex:tel ?telefon . }

    VorteilStukturiertes Ergebnis mit Beziehungen zwischen Elementen

    NachteileI Sequentielle Abarbeitung von Ergebnissen erschwertI Keine Behandlung von ungebundenen Variablen

  • 45/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Weitere Formate: ASK und DESCRIBE

    SPARQL untersttzt zwei weitere Ausgabeformate:I ASK prft nur, ob es Ergebnisse gibt, keine ParameterI DESCRIBE (informativ) liefert zu jeder gefundenen URI

    eine RDF-Beschreibung (anwendungsabhngig)

    DESCRIBE ?x WHERE { ?x "1234" }

    Kann als Ergebnis z.B. die folgende Ausgabe haben (ohnePrefix Deklarationen):

    _:a exOrg:employeeId "1234" ;foaf:mbox_sha1sum "ABCD1234" ;vcard:N[ vcard:Family "Smith" ;vcard:Given "John" ] .

    foaf:mbox_sha1sum rdf:type owl:InverseFunctionalProperty .

  • 46/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Wozu Modifikatoren?

    Bisher nur grundstzliche Formatierungseinstellungen frErgebnisse:I Wie kann man definierte Teile der Ergebnismenge

    abfragen?I Wie werden Ergebnisse geordnet?I Knnen wiederholte Ergebniszeilen sofort entfernt

    werden? Modifikatoren der Lsungssequenz (solution sequencemodifiers)

  • 47/51 Birte Glimm | Linked Data & SPARQL | 12. Mai 2012

    Ergebnisse SortierenSortierung von Ergebnissen mit Schlsselwort ORDER BY

    SELECT ?book ?priceWHERE { ?book ?price . }ORDER BY ?price

    I Sortierung wie bei Filter-Vergleichoperatoren,I Sortierung von URIs alphabetisch als ZeichenkettenI Reihenfolge zwischen unterschiedlichen Arten von

    Elementen:Ungebundene Variable < leere Knoten < URIs