0
Querying Linked DataPresented by:Barry Norton
Motivation: Music!2VisualizationModuleMetadataStreaming providersPhysical WrapperDownloadsDataacquisitionD2R Transf.LD Wra...
Agenda1. Introduction to SPARQL2. Querying Linked Data with SPARQL3. SPARQL Algebra4. Updating Linked Data with SPARQL 1.1...
INTRODUCTIONTO SPARQLEUCLID - Querying Linked Data 4
SPARQLEUCLID - Querying Linked Data 5Semantic Web StackBerners-Lee (2006)* Protocol and RDF Query LanguageDeclarative quer...
SPARQLEUCLID - Querying Linked Data 6• SPARQL Query– Declarative query language for RDF data– http://www.w3.org/TR/rdf-spa...
SPARQL Query 1.1EUCLID - Querying Linked Data 7• SPARQL 1.0 only allows accessing the data (query)• SPARQL 1.1 introduces:...
SPARQL BasicsEUCLID - Querying Linked Data 8• RDF triple: Basic building block, of the formsubject, predicate, object. Exa...
SPARQL BasicsEUCLID - Querying Linked Data 9• RDF graph: Set of RDF assertions, manipulated asa labeled directed graph.• R...
QUERYING LINKED DATA WITHSPARQLEUCLID - Querying Linked Data 10
SPARQL QueryEUCLID - Querying Linked Data 11Main idea: Pattern matching• Queries describe sub-graphs of the queried graph•...
SPARQL QueryEUCLID - Querying Linked Data 12?albumdbpedia:The_Beatlesfoaf:madedbpedia:The_Beatlesfoaf:made<http://musicbra...
SPARQL QueryEUCLID - Querying Linked Data 13?albumdbpedia:The_Beatlesdbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/r...
SPARQL QueryEUCLID - Querying Linked Data 14?albumdbpedia:The_Beatlesdbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/r...
SPARQL Query: ComponentsEUCLID - Querying Linked Data 15PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http:/...
SPARQL Query: ComponentsEUCLID - Querying Linked Data 16Query form:• ASK, SELECT, DESCRIBE or CONSTRUCT• SELECT retrieves ...
SPARQL Query: ComponentsEUCLID - Querying Linked Data 17Data set specification:• This clause is optional• FROM or FROM NAM...
SPARQL Query: ComponentsEUCLID - Querying Linked Data 18Query pattern:• Defines patterns to match against the data• Genera...
Solution modifier:• Modify the result set• ORDER BY, LIMIT or OFFSET re-organise rows;• GROUP BY combines themSPARQL Query...
Query FormsEUCLID - Querying Linked Data 20SPARQL supports different query forms:• ASK tests whether or not a query patter...
Query Form: ASKEUCLID - Querying Linked Data 21• Namespaces are added with the ‘PREFIX’ directive• Statement patterns that...
Query Form: SELECTEUCLID - Querying Linked Data 22• The solution modifier projection nominates whichcomponents of the matc...
Filter expressions• Different types of filters and functions may be usedQuery Form: SELECT (2)EUCLID - Querying Linked Dat...
Query Form: SELECT (3)EUCLID - Querying Linked Data 24Elimination of duplicatesPREFIX dbpedia: <http://dbpedia.org/resourc...
Aggregates• Calculate aggregate values: COUNT, SUM, MIN, MAX, AVG,GROUP_CONCAT and SAMPLE• Built around the GROUP BY opera...
Query Form: DESCRIBEEUCLID - Querying Linked Data 26Takes the resources within the solution, and providesinformation about...
EUCLID - Querying Linked Data 27• CONSTRUCT WHERE: In order to query for asubgraph, without change, it is no longer necess...
Query Form: CONSTRUCT (2a)EUCLID - Querying Linked Data 28dbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/record/...><...
EUCLID - Querying Linked Data 29• Returns RDF statements created from variablebindings• Template: graph pattern with varia...
Query Form: CONSTRUCT (3)EUCLID - Querying Linked Data 30Subsets of results• It is possible to combine the query with solu...
Union Graph Pattern• Allows the specification of alternatives (disjunctions)EUCLID - Querying Linked Data 31PREFIX dbpedia...
Filter expressions• Different types of filters and functions may be usedEUCLID - Querying Linked Data 32PREFIX dbpedia: <h...
Type of function Function Result typeFunctional FormsboundIFCOALESCENOT EXISTS, EXISTSor, andRDFTerm-equal (=), sameTermIN...
Type of function Function Result typeFunctions on Strings STRLENSUBSTR, UCASE, LCASESTRSTARTS, STRENDS, CONTAINSSTRBEFORE,...
Optional Graph Pattern• OPTIONAL clause encloses the optional parts• If variables in the construct clause are not bound in...
Optional Graph Pattern• Can test if variables are bound in filter expressions• Solutions that meet the OPTIONAL clause can...
Assigning Variables• The value of an expression can be added to a solution mapping bybinding a new variable (which can be ...
Sub-queries and Aggregate Values• To combine the CONSTRUCT query form with aggregate values, asub-query should be created ...
UPDATING LINKED DATA WITHSPARQL 1.1EUCLID - Querying Linked Data 39
Data ManagementEUCLID - Querying Linked Data 40SPARQL 1.1 provides data update operations:• INSERT data: adds some triples...
Data Management (2)EUCLID - Querying Linked Data 41INSERT dataPREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX foaf: <h...
Data Management (3)EUCLID - Querying Linked Data 42DELETE dataDelete all the information about the album Casualities of Th...
Data Management (4)EUCLID - Querying Linked Data 43DELETE/INSERT dataPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX ...
Graph ManagementEUCLID - Querying Linked Data 44SPARQL 1.1 provides graph update operations:• CREATE: creates an empty gra...
Graph Management (2)EUCLID - Querying Linked Data 45CREATE• Creates a new named graph• Can be used with the DEFAULT and AL...
Graph Management (3)EUCLID - Querying Linked Data 46CLEAR• Removes all triples in the graph (it is emptied but not deleted...
Graph Management (4)EUCLID - Querying Linked Data 47SPARQL 1.1 provides other graph management operations:• COPY …TO …• MO...
SPARQL PROTOCOL FOR RDFEUCLID - Querying Linked Data 48
SPARQL 1.1. ProtocolEUCLID - Querying Linked Data 49• Consists of two operations: query and update• An operation defines:•...
EUCLID - Querying Linked Data 50• Sends a SPARQL query to a service and receives the results ofthe query• The response is:...
EUCLID - Querying Linked Data 51Example:PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX dbpedia-ont: <http://dbpedia....
Update OperationEUCLID - Querying Linked Data 52• Sends a SPARQL update request to a service• Should be invoked using the ...
REASONING OVER LINKED DATAEUCLID - Querying Linked Data 53
Reasoning forLinked Data IntegrationEUCLID - Querying Linked Data 54• Example: Integration of the MusicBrainz data set and...
Reasoning forLinked Data IntegrationEUCLID - Querying Linked Data 55mo:b10bbbfc-cf9e-42e0-be17-e2c3e1d2600dfoaf:name The B...
Reasoning forLinked Data IntegrationEUCLID - Querying Linked Data 56mo:b10bbbfc-cf9e-42e0-be17-e2c3e1d2600dfoaf:name The B...
SPARQL 1.1:Entailment RegimesEUCLID - Querying Linked Data 57• SPARQL 1.0 was defined only for simple entailment(pattern m...
RDFSEUCLID - Querying Linked Data 58Resource Description Framework SchemaSemantic Web StackBerners-Lee (2006)Taxonomies an...
RDFS Entailment RegimesEUCLID - Querying Linked Data 59• Contains 13 entailment rules denominated rdfsi forinference over ...
rdfs2 – rdfs:domainEUCLID - Querying Linked Data 60dbpedia:The_Beatlesdbpedia:Paul_McCartneySELECT ?x WHERE {?x a mo:Music...
rdfs3 – rdfs:rangeEUCLID - Querying Linked Data 61dbpedia:The_Beatlesdbpedia:Paul_McCartneySELECT ?x WHERE {?x a foaf:Agen...
rdfs7 – rdfs:subPropertyOfEUCLID - Querying Linked Data 62dbpedia:Yesterdaydbpedia:Paul_McCartneySELECT ?x WHERE {dbpedia:...
rdfs9 – rdfs:subClassOfEUCLID - Querying Linked Data 63dbpedia:The_BeatlesSELECT ?x WHERE {?x a mo:MusicArtist.}mo:MusicGr...
Inference from SchemaEUCLID - Querying Linked Data 64• Knowledge encoded in the schema leads to infer newfacts• This is al...
RDFS:Lack of Consistency CheckEUCLID - Querying Linked Data 65• It is possible to infer facts that seem incorrect facts,bu...
• We might wish further inferences, but these arebeyond the entailment rules implemented by RDFSRDFS:Inference Limitations...
OWLEUCLID - Querying Linked Data 67Web Ontology LanguageSemantic Web StackBerners-Lee (2006)Ontologies and inferences
Introduction to OWLEUCLID - Querying Linked Data 68• Provides more ontological constructs and avoids some ofthe potential ...
OWL PropertiesEUCLID - Querying Linked Data 69OWL distinguishes between two types of properties:• OWL ObjectProperties: re...
PropertyAxiomsEUCLID - Querying Linked Data 70• Property axioms include those from RDF Schema• OWL allows for property equ...
PropertyAxiomsEUCLID - Querying Linked Data 71• Property axioms include those from RDF Schema• OWL allows for property equ...
PropertyAxioms (2)EUCLID - Querying Linked Data 72OWL allows the definition of property characteristics to infer newfacts ...
Property Axioms:SymmetryEUCLID - Querying Linked Data 73dbpedia:The_Beatlesdbpedia:Billy_Prestondbpedia:Plastic_Ono_Band :...
Property Axioms:TransitivityEUCLID - Querying Linked Data 74:Rock:Heavy_metal:Black_metal:Punk_rockSELECT ?genre WHERE {:R...
Property Axioms:InverseEUCLID - Querying Linked Data 75SELECT ?x WHERE {?x mo:member_ofdbpedia:The_Beatles .}mo:member_of ...
Example: Every artist primarily playsonly one musical instrumentmo:primary_instrument rdf:type owl:FunctionalProperty .dbp...
Example: Every recording has a unique ISRC(International Standard Recording Code)mo:isrc rdf:type owl:InverseFunctionalPro...
Individual AxiomsEUCLID - Querying Linked Data 78OWL Individuals represent instances of classes. They are related totheir ...
Class AxiomsEUCLID - Querying Linked Data 79Axioms declare general statements about concepts which are usedin logical infe...
Class ConstructionEUCLID - Querying Linked Data 80• OWL classes are defined by the OWL term owl:Class• OWL classes can be ...
Class Construction (2)EUCLID - Querying Linked Data 81These class constructs are available in OWL, not in RDFSThe class of...
Naming Class ConstructionsEUCLID - Querying Linked Data 82• Direct naming can be achieved via owl:equivalentClass• This co...
SummaryEUCLID - Querying Linked Data 83• Basic concepts: triple patterns, graph patterns, SPARQL endpoint ...• SPARQL Quer...
Summary (2)EUCLID - Querying Linked Data 84• Reasoning over Linked Data:• SPARQL 1.1 entailment regimes• RDFS: entailment ...
For exercises, quiz and further material visit our website:EUCLID - Providing Linked Data 85@euclid_project euclidproject ...
Acknowledgements• Alexander Mikroyannidis• Alice Carpentier• Andreas Harth• Andreas Wagner• Andriy Nikolov• Barry Norton• ...
Upcoming SlideShare
Loading in...5
×

Querying Linked Data

5,222

Published on

This presentation looks in detail at SPARQL (SPARQL Protocol and RDF Query Language) and introduces approaches for querying and updating semantic data. It covers the SPARQL algebra, the SPARQL protocol, and provides examples for reasoning over Linked Data. We use examples from the music domain, which can be directly tried out and ran over the MusicBrainz dataset. This includes gaining some familiarity with the RDFS and OWL languages, which allow developers to formulate generic and conceptual knowledge that can be exploited by automatic reasoning services in order to enhance the power of querying.

Published in: Technology, Business
5 Comments
4 Likes
Statistics
Notes
  • The webinars to the slides are available at: Part I http://vimeo.com/61618438 Part II http://vimeo.com/61618437
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • From Slide 22 the newer MusicBrainz mapping has a finer-grained distinction between 'album' (SignalGroup), and 'record' (the container of tracks), which is an artifact of a 'release' (of the album at a point in time). The examples are all encoded fully at:
    http://euclid.sti2.org/Exercises/Exercise2

    (Login is exercise2/exercise2)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • On Slide 23 the variable ?date in the projection does not belong
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Angle brackets are missing around the Music Ontology's namespace on Slide 21 (and the DBpedia ontology namespace is unneeded).
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • On Slide 32 the regex is over-defined.

    Without a start of string anchor ('^'), or an end of string anchor ('$'), it's unnecessary to have match-alls ('.*'). The substring will match with just ('love').
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
5,222
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
214
Comments
5
Likes
4
Embeds 0
No embeds

No notes for slide
  • NOTE: the “CH 1” means that these topics were covered in EUCLID Chapter 1 already.
  • NOTE: the “CH 1” means that these topics were covered in EUCLID Chapter 1 already.
  • NOTE: the “CH 1” means that these topics were covered in EUCLID Chapter 1 already.
  • NOTE: the “CH 1” means that these topics were covered in EUCLID Chapter 1 already.
  • NOTE: the “CH 1” means that these topics were covered in EUCLID Chapter 1 already.
  • Transcript of "Querying Linked Data"

    1. 1. Querying Linked DataPresented by:Barry Norton
    2. 2. Motivation: Music!2VisualizationModuleMetadataStreaming providersPhysical WrapperDownloadsDataacquisitionD2R Transf.LD WrapperMusical ContentApplicationAnalysis &Mining ModuleLDDatasetAccessLD WrapperRDF/XMLIntegratedDatasetInterlinking CleansingVocabularyMappingSPARQLEndpointPublishingRDFaOther content
    3. 3. Agenda1. Introduction to SPARQL2. Querying Linked Data with SPARQL3. SPARQL Algebra4. Updating Linked Data with SPARQL 1.15. SPARQL Protocol6. Reasoning over Linked Data3EUCLID - Querying Linked Data
    4. 4. INTRODUCTIONTO SPARQLEUCLID - Querying Linked Data 4
    5. 5. SPARQLEUCLID - Querying Linked Data 5Semantic Web StackBerners-Lee (2006)* Protocol and RDF Query LanguageDeclarative query language
    6. 6. SPARQLEUCLID - Querying Linked Data 6• SPARQL Query– Declarative query language for RDF data– http://www.w3.org/TR/rdf-sparql-query/• SPARQL Algebra– Standard for communication between SPARQL services and clients– http://www.w3.org/2001/sw/DataAccess/rq23/rq24-algebra.html• SPARQL Update– Declarative manipulation language for RDF data– http://www.w3.org/TR/sparql11-update/• SPARQL Protocol– Standard for communication between SPARQL services and clients– http://www.w3.org/TR/sparql11-protocol/
    7. 7. SPARQL Query 1.1EUCLID - Querying Linked Data 7• SPARQL 1.0 only allows accessing the data (query)• SPARQL 1.1 introduces:Query extensionsUpdates• Data management:Insert, Delete, Delete/Insert• Graph management:Create, Load, Clear, Drop, Copy, Move, Add• Aggregates, Subqueries, Negation, Expressions in the SELECTclause, Propertypaths, assignment, short form forCONSTRUCT, expanded set offunctions and operatorsFederation extension • Service, values, service variables(informative) CH 5
    8. 8. SPARQL BasicsEUCLID - Querying Linked Data 8• RDF triple: Basic building block, of the formsubject, predicate, object. Example:• RDF triple pattern: Contains one or more variables.Examples:• RDF quad pattern: Contains graph name: URI or variable.Examples:dbpedia:The_Beatles foaf:name "The Beatles" .dbpedia:The_Beatles foaf:made ?album.?album mo:track ?track .?album ?p ?o .GRAPH <:g> {:s :p :o .}GRAPH ?g {dbpedia:The_Beatles foaf:name ?o.}
    9. 9. SPARQL BasicsEUCLID - Querying Linked Data 9• RDF graph: Set of RDF assertions, manipulated asa labeled directed graph.• RDF data set: set of RDF triples. It is comprised of:• One default graph• Zero or more named graphs• SPARQL protocol client: HTTP client that sends requests forSPARQL Protocol operations (queries or updates)• SPARQL protocol service: HTTP server that services requests forSPARQL Protocol operations• SPARQL endpoint: The URI at which a SPARQL Protocol servicelistens for requests from SPARQL clients
    10. 10. QUERYING LINKED DATA WITHSPARQLEUCLID - Querying Linked Data 10
    11. 11. SPARQL QueryEUCLID - Querying Linked Data 11Main idea: Pattern matching• Queries describe sub-graphs of the queried graph• Graph patterns are RDF graphs specified in Turtlesyntax, which contain variables (prefixed by either “?” or “$”)• Sub-graphs that match the graph patterns yield aresult?albumdbpedia:The_Beatlesfoaf:made
    12. 12. SPARQL QueryEUCLID - Querying Linked Data 12?albumdbpedia:The_Beatlesfoaf:madedbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/record/...><http://musicbrainz.org/record/...>foaf:madeData:Graph pattern:Results:"Help!" "Let It Be"dc:title dc:title<http://musicbrainz.org/record/...>"Abbey Road"dc:titlefoaf:made?album<http://musicbrainz.org...><http://musicbrainz.org...><http://musicbrainz.org...>
    13. 13. SPARQL QueryEUCLID - Querying Linked Data 13?albumdbpedia:The_Beatlesdbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/record/...><http://musicbrainz.org/record/...>foaf:madeData:Graph pattern:Results:"Help!" "Let It Be"dc:title dc:title<http://musicbrainz.org/record/...>"Abbey Road"dc:titlefoaf:made?album ?title<http://...> "Help!"<http://...> "Abbey Road"<http://...> "Let It Be"?titledc:title
    14. 14. SPARQL QueryEUCLID - Querying Linked Data 14?albumdbpedia:The_Beatlesdbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/record/...><http://musicbrainz.org/track/...>foaf:madeData:Graph pattern:Results:"Help!" "Help!"dc:title dc:titlemo:trackamo:Record mo:Trackmo:Record?album<http://musicbrainz.org...>
    15. 15. SPARQL Query: ComponentsEUCLID - Querying Linked Data 15PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?albumFROM <http://musicbrainz.org/20130302>WHERE {dbpedia:The_Beatles foaf:made ?album .?album a mo:Record ; dc:title ?title}ORDER BY ?titlePrologue:• Prefix definitions• Subtly different from Turtle syntax - the final period is not used
    16. 16. SPARQL Query: ComponentsEUCLID - Querying Linked Data 16Query form:• ASK, SELECT, DESCRIBE or CONSTRUCT• SELECT retrieves variables and their bindings as a tablePREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?albumFROM <http://musicbrainz.org/20130302>WHERE {dbpedia:The_Beatles foaf:made ?album .?album a mo:Record ; dc:title ?title}ORDER BY ?title
    17. 17. SPARQL Query: ComponentsEUCLID - Querying Linked Data 17Data set specification:• This clause is optional• FROM or FROM NAMED• Indicates the sources for the data against which to find matchesPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?albumFROM <http://musicbrainz.org/20130302>WHERE {dbpedia:The_Beatles foaf:made ?album .?album a mo:Record ; dc:title ?title}ORDER BY ?title
    18. 18. SPARQL Query: ComponentsEUCLID - Querying Linked Data 18Query pattern:• Defines patterns to match against the data• Generalises Turtle with variables and keywords – N.B. final period optionalPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?albumFROM <http://musicbrainz.org/20130302>WHERE {dbpedia:The_Beatles foaf:made ?album .?album a mo:Record ; dc:title ?title}ORDER BY ?title
    19. 19. Solution modifier:• Modify the result set• ORDER BY, LIMIT or OFFSET re-organise rows;• GROUP BY combines themSPARQL Query: ComponentsEUCLID - Querying Linked Data 19PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?albumFROM <http://musicbrainz.org/20130302>WHERE {dbpedia:The_Beatles foaf:made ?album .?album a mo:Record ; dc:title ?title}ORDER BY ?title
    20. 20. Query FormsEUCLID - Querying Linked Data 20SPARQL supports different query forms:• ASK tests whether or not a query pattern has asolution. Returns yes/no• SELECT returns variables and their bindingsdirectly• CONSTRUCT returns a single RDF graph specifiedby a graph template• DESCRIBE returns a single RDF graph containingRDF data about resource
    21. 21. Query Form: ASKEUCLID - Querying Linked Data 21• Namespaces are added with the ‘PREFIX’ directive• Statement patterns that make up the graph arespecified between brackets (“{}”)PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX dbpedia-ont: <http://dbpedia.org/ontology/>PREFIX mo: http://purl.org/ontology/mo/ASK WHERE { dbpedia:The_Beatles mo:memberdbpedia:Paul_McCartney.}Is Paul McCartney member of ‘The Beatles’?Query:trueResults:Is Elvis Presley member of ‘The Beatles’?Query:falseResults:PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX dbpedia-ont: <http://dbpedia.org/ontology/>PREFIX mo: http://purl.org/ontology/mo/ASK WHERE { dbpedia:The_Beatles mo:memberdbpedia:Elvis_Presley.}
    22. 22. Query Form: SELECTEUCLID - Querying Linked Data 22• The solution modifier projection nominates whichcomponents of the matches should be returned• “*” means all components should be returnedPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?album_name ?track_titleWHERE {dbpedia:The_Beatles foaf:made ?album .?album dc:title ?album_name ;mo:track ?track .?track dc:title ?track_title .}Query: What albums and tracks did ‘The Beatles’ make?
    23. 23. Filter expressions• Different types of filters and functions may be usedQuery Form: SELECT (2)EUCLID - Querying Linked Data 23PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?album_name ?track_title ?date ?durationWHERE {dbpedia:The_Beatles foaf:made ?album .?album dc:title ?album_name ;mo:track ?track .?track dc:title ?track_title ;mo:duration ?duration;FILTER (?duration>300000 && ?duration<400000) }Query:Filter: Comparison and logical operatorsRetrieve the albums and tracks recorded by ‘The Beatles’, where theduration of the song is more than 300 secs. and no longer than 400 secs.
    24. 24. Query Form: SELECT (3)EUCLID - Querying Linked Data 24Elimination of duplicatesPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT MODIFIER ?album_nameWHERE {dbpedia:The_Beatles foaf:made ?album .?album dc:title ?album_name .mo:track ?track1 .mo:track ?track2 .FILTER (?track1 != ?track2) }Retrieve the name of the albums recorded by ‘The Beatles’which have at least two different songs.Query:?album“Revolver”“Sessions”“Abbey Road”?album“Revolver”“Revolver”“Revolver”“Sessions”“Abbey Road”“Abbey Road”DISTINCTResults:REDUCEDMODIFIER= MODIFIER=
    25. 25. Aggregates• Calculate aggregate values: COUNT, SUM, MIN, MAX, AVG,GROUP_CONCAT and SAMPLE• Built around the GROUP BY operator• Prune at group level (cf. FILTER) using HAVINGQuery Form: SELECT (4)EUCLID - Querying Linked Data 25PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX mo: <http://purl.org/ontology/mo/>SELECT ?album (SUM(?track_duration) AS ?album_duration)WHERE {dbpedia:The_Beatles foaf:made ?album .?album mo:track ?track .?track mo:duration ?track_duration .} GROUP BY ?albumHAVING (SUM(?track_duration) > 3600000)Retrieve the duration of the albums recorded by ‘The Beatles’.Query:
    26. 26. Query Form: DESCRIBEEUCLID - Querying Linked Data 26Takes the resources within the solution, and providesinformation about them as RDF statements. They canbe identified by:• Specifying explicit IRIs• Bindings of variables in the WHERE clausePREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX mo: <http://purl.org/ontology/mo/>DESCRIBE ?memberWHERE {dbpedia:The_Beatles mo:member ?member .}PREFIX dbpedia: <http://dbpedia.org/resource/>DESCRIBE dbpedia:Paul_McCartney
    27. 27. EUCLID - Querying Linked Data 27• CONSTRUCT WHERE: In order to query for asubgraph, without change, it is no longer necessaryto repeat the graph pattern in the templatePREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX mo: <http://purl.org/ontology/mo/>PREFIX dc: <http://purl.org/dc/elements/1.1/>CONSTRUCT WHERE {dbpedia:The_Beatles foaf:made ?album .?album mo:track ?track .}Example:Query Form: CONSTRUCT
    28. 28. Query Form: CONSTRUCT (2a)EUCLID - Querying Linked Data 28dbpedia:The_Beatlesfoaf:made<http://musicbrainz.org/record/...><http://musicbrainz.org/record/...>foaf:madeData:Query: Result:"Help!" "Let It Be"dc:title dc:title<http://musicbrainz.org/record/...>"Abbey Road"dc:titlefoaf:madeCONSTRUCT {?album dc:creator dbpedia:The_Beatles .}WHERE {dbpedia:The_Beatles foaf:made ?album .}dbpedia:The_Beatles<http://musicbrainz…><http://musicbrainz…><http://musicbrainz…>dc:creatordc:creatordc:creator
    29. 29. EUCLID - Querying Linked Data 29• Returns RDF statements created from variablebindings• Template: graph pattern with variables from thequery patternPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX mo: <http://purl.org/ontology/mo/>PREFIX dc: <http://purl.org/dc/elements/1.1/>CONSTRUCT {?album dc:creator dbpedia:The_Beatles .?track dc:creator dbpedia:The_Beatles .}WHERE {dbpedia:The_Beatles foaf:made ?album .?album mo:track ?track .}Create the dc:creator descriptions for albums and their tracksrecorded by ‘The Beatles’.Query:Query Form: CONSTRUCT (2b)
    30. 30. Query Form: CONSTRUCT (3)EUCLID - Querying Linked Data 30Subsets of results• It is possible to combine the query with solution modifiers(ORDER BY, LIMIT, OFFSET)PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX mo: <http://purl.org/ontology/mo/>PREFIX dc: <http://purl.org/dc/elements/1.1/>CONSTRUCT {?album dc:creator dbpedia:The_Beatles .?track dc:creator dbpedia:The_Beatles .}WHERE {dbpedia:The_Beatles foaf:made ?album .?album mo:track ?track ;dc:date ?date .} ORDER BY DESC(?date)LIMIT 10Create the dc:creator descriptions for the 10 most recentalbums and their tracks recorded by ‘The Beatles’.Query:
    31. 31. Union Graph Pattern• Allows the specification of alternatives (disjunctions)EUCLID - Querying Linked Data 31PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: http://xmlns.com/foaf/0.1/PREFIX dc: <http://purl.org/dc/elements/1.1/>CONSTRUCT {?album dc:creator dbpedia:The_Beatles .?track dc:creator dbpedia:The_Beatles .}WHERE {dbpedia:The_Beatles foaf:made ?album .?album dc:title ?album_name .{?album dbpedia-ont:recordedIn dbpedia:Abbey_Road_Studios .}UNION{?album dbpedia-ont:recordedIn dbpedia:Trident_Studios .}}Create the dc:creator descriptions for the albums recorded by‘The Beatles’ in ‘Abbey Road Studios’ or ‘Trident Studios’Query:Query Form: CONSTRUCT (4)
    32. 32. Filter expressions• Different types of filters and functions may be usedEUCLID - Querying Linked Data 32PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>CONSTRUCT {?album dc:creator dbpedia:The_Beatles .}WHERE {dbpedia:The_Beatles foaf:made ?album .?album dc:title ?album_name ;FILTER (REGEX(?album_name, ".*love.*", i)) }Query:Filter: Regular expressions over stringsCreate the dc:creator descriptions of the albums recorded by‘The Beatles’ whose title contains the word ‘love .Query Form: CONSTRUCT (5)
    33. 33. Type of function Function Result typeFunctional FormsboundIFCOALESCENOT EXISTS, EXISTSor, andRDFTerm-equal (=), sameTermIN, NOT INxsd:booleanrdfTermrdfTermxsd:booleanxsd:booleanxsd:booleanbooleanFunctions on RDF TermsisIRI, isBlank, isLiteral, isNumericstr, lang,datatypeIRIBNODExsd:booleansimple literaliriiriblank nodeFunctions on Numerics ABS, ROUND, CEIL, FLOORRANDnumericxsd:doubleFilter expressionsEUCLID - Querying Linked Data 33Source:http://www.w3.org/TR/sparql11-query/#SparqlOpsQuery Form: CONSTRUCT (6)
    34. 34. Type of function Function Result typeFunctions on Strings STRLENSUBSTR, UCASE, LCASESTRSTARTS, STRENDS, CONTAINSSTRBEFORE, STRAFTERENCODE_FOR_URICONCATlangMatchesREGEXREPLACExsd:integerstring literalxsd:booleanliteralsimple literalstring literalxsd:booleanxsd:booleanstring literalFunctions on Dates andTimesnowyear, month, day, hours, minutessecondstimezonetzxsd:dateTimexsd:integerxsd:decimalxsd:dayTimeDurationsimple literalFilter expressionsEUCLID - Querying Linked Data 34Source:http://www.w3.org/TR/sparql11-query/#SparqlOpsQuery Form: CONSTRUCT (7)
    35. 35. Optional Graph Pattern• OPTIONAL clause encloses the optional parts• If variables in the construct clause are not bound in the optional,the triple patterns with these variables are not generatedEUCLID - Querying Linked Data 35PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>CONSTRUCT {?album dc:creator ?artist .?picture dc:depicts ?artist . }WHERE {?artist foaf:made ?album .OPTIONAL {?artist foaf:depiction ?picture .}}Create the dc:creator and dc:depicts descriptions of artists.Query:Query Form: CONSTRUCT (8)
    36. 36. Optional Graph Pattern• Can test if variables are bound in filter expressions• Solutions that meet the OPTIONAL clause can be filtered out byusing the logical filter NOT (!)EUCLID - Querying Linked Data 36PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>CONSTRUCT { ?album dc:creator ?artist . }WHERE {?artist foaf:made ?album .OPTIONAL {?artist dbpedia-owl:deathPlace ?place_of_death .}FILTER (!BOUND(?place_of_death))}Create the dc:creator descriptions of those artists who are notdead.Query:Query Form: CONSTRUCT (9)NOT EXISTS {?artist dbpedia-owl:deathPlace ?place_of_death .}
    37. 37. Assigning Variables• The value of an expression can be added to a solution mapping bybinding a new variable (which can be further used and returned)• The BIND form allows to assign a value to a variable from a BGPEUCLID - Querying Linked Data 37PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX mo: <http://purl.org/ontology/mo/>PREFIX dbpedia-ont: <http://dbpedia.org/ontology/>CONSTRUCT { ?track dbpedia-ont:runtime ?secs .}WHERE {dbpedia:The_Beatles foaf:made ?album .?album mo:track ?track .?track mo:duration ?duration .BIND((?duration/1000) AS ?secs) .}Calculate the duration of the tracks from ms to s, and store thevalue using the dbpedia-ont:runtime property .Query:Query Form: CONSTRUCT (10)
    38. 38. Sub-queries and Aggregate Values• To combine the CONSTRUCT query form with aggregate values, asub-query should be created inside the WHERE clauseEUCLID - Querying Linked Data 38PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>PREFIX mo: <http://purl.org/ontology/mo/>CONSTRUCT {?album music-ont:duration ?album_duration .}WHERE {SELECT ?album (SUM(?track_duration) AS ?album_duration) {dbpedia:The_Beatles foaf:made ?album .?album mo:track ?track .?track mo:duration ?track_duration .} GROUP BY ?albumHAVING (SUM(?track_duration) > 3600000)}Materialize the duration of the albums recorded by ‘The Beatles’.Query:Query Form: CONSTRUCT (11)
    39. 39. UPDATING LINKED DATA WITHSPARQL 1.1EUCLID - Querying Linked Data 39
    40. 40. Data ManagementEUCLID - Querying Linked Data 40SPARQL 1.1 provides data update operations:• INSERT data: adds some triples, given inline in the request,into a graph• DELETE data: removes some triples, given inline in therequest, if the respective graphs contains those• DELETE/INSERT data: uses in parallel INSERT andDELETECH 1CH 1
    41. 41. Data Management (2)EUCLID - Querying Linked Data 41INSERT dataPREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>INSERT DATA { GRAPH { <http://musicbrainz.org/20130302><http://musicbrainz.org/artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d>foaf:made <http://musicbrainz.org/release/3a685770-7326-34fc-9f18-e5f5626f3dc5> ,< http://musicbrainz.org/release/cb6f8798-d51e-4fa5-a4d1-2c0602bfe1b6 > .<http://musicbrainz.org/release/3a685770-7326-34fc-9f18-e5f5626f3dc5>dc:title "Please Please Me".< http://musicbrainz.org/release/cb6f8798-d51e-4fa5-a4d1-2c0602bfe1b6 >dc:title "Something New". } }Insert the following albums recorded byThe Beatles into the graphhttp://musicbrainz.org/20130209-004702CH 1
    42. 42. Data Management (3)EUCLID - Querying Linked Data 42DELETE dataDelete all the information about the album Casualities of The Beatles.PREFIX dc: <http://purl.org/dc/elements/1.1/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>DELETE { ?album ?predicate ?object . }WHERE {<http://musicbrainz.org/artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d>foaf:made ?album .?album dc:title "Casualities".?album ?predicate ?object .}CH 1
    43. 43. Data Management (4)EUCLID - Querying Linked Data 43DELETE/INSERT dataPREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX db-ont: <http://dbpedia.org/ontology/>PREFIX foaf: <http://xmlns.com/foaf/0.1/>DELETE { dbpedia:The_Beatles db-ont:currentMember ?x . }INSERT { GRAPH <http://musicbrainz.org/20130209-004702> {dbpedia:The_Beatles db-ont:formerBandMember ?x .}}WHERE {dbpedia:The_Beatles db-ont:currentMember ?x .?x foaf:name "Peter Best" .}Delete the status of ‘Peter Best’ as current member of´The Beatles´,and insert his status as former member of the band.
    44. 44. Graph ManagementEUCLID - Querying Linked Data 44SPARQL 1.1 provides graph update operations:• CREATE: creates an empty graph in the Graph Store• LOAD: reads the content of a document into a graph inthe Graph Store• CLEAR: removes all triples in one or more graphs• DROP: removes the graph from the Graph Store• Other operations: COPY, MOVE, ADD
    45. 45. Graph Management (2)EUCLID - Querying Linked Data 45CREATE• Creates a new named graph• Can be used with the DEFAULT and ALL keywordsLOAD• An RDF graph can be loaded from a URL• LOAD can be used with the SILENT keywordCREATE GRAPH <http://musicbrainz.org/20130302>LOAD <http://xmlns.com/foaf/spec/20100809.rdf>LOAD <http://xmlns.com/foaf/spec/20100809.rdf>INTO <http://xmlns.com/foaf/0.1/>Named graph
    46. 46. Graph Management (3)EUCLID - Querying Linked Data 46CLEAR• Removes all triples in the graph (it is emptied but not deleted!)• The graph(s) can be specified with the following keywords:DEFAULT, NAMED, ALL, GRAPH• Can be used with the SILENT keywordDROP• The given graph is removed from the Graph Store, including itscontent• Can be used with the DEFAULT and ALL keywordsCLEAR GRAPH <http://musicbrainz.org/20130302>DROP GRAPH <http://musicbrainz.org/20130302>
    47. 47. Graph Management (4)EUCLID - Querying Linked Data 47SPARQL 1.1 provides other graph management operations:• COPY …TO …• MOVE …TO …• ADD …TO …COPY GRAPH <http://musicbrainz.org/20130302>TO GRAPH <http://musicbrainz.org/20130303>MOVE GRAPH <http://musicbrainz.org/temp>TO GRAPH <http://musicbrainz.org/20130303>ADD GRAPH <http://musicbrainz.org/20130302>TO GRAPH <http://musicbrainz.org/20130303>
    48. 48. SPARQL PROTOCOL FOR RDFEUCLID - Querying Linked Data 48
    49. 49. SPARQL 1.1. ProtocolEUCLID - Querying Linked Data 49• Consists of two operations: query and update• An operation defines:• The HTTP method (GET or POST)• The HTTP query string parameters• The message content included in the HTTP request body• The message content included in the HTTP response bodySPARQL Client SPARQL EndpointRequestalt [no errors][else]Success ResponseFailure Response
    50. 50. EUCLID - Querying Linked Data 50• Sends a SPARQL query to a service and receives the results ofthe query• The response is:• May be invoked using HTTP GET or HTTP POST. The methodPOST with URL encoding is mostly used when the query stringis too longQuery OperationXML, JSON, CSV/TSV from a SELECT queryRDF/XML, Turtle from a CONSTRUCT query
    51. 51. EUCLID - Querying Linked Data 51Example:PREFIX dbpedia: <http://dbpedia.org/resource/>PREFIX dbpedia-ont: <http://dbpedia.org/ontology/>SELECT ?albumWHERE { ?album dbpedia-ont:artist dbpedia:The_Beatles .}LIMIT 3SPARQL Query:Query Operation (2)HTTP GET request:Try this query!(Click on the hurl icon)
    52. 52. Update OperationEUCLID - Querying Linked Data 52• Sends a SPARQL update request to a service• Should be invoked using the HTTP PATCH/POSTmethod• The response consists of a HTTP response statuscode, which indicates success or failure of theoperation
    53. 53. REASONING OVER LINKED DATAEUCLID - Querying Linked Data 53
    54. 54. Reasoning forLinked Data IntegrationEUCLID - Querying Linked Data 54• Example: Integration of the MusicBrainz data set andthe DBpedia data setIntegrationData set Data set
    55. 55. Reasoning forLinked Data IntegrationEUCLID - Querying Linked Data 55mo:b10bbbfc-cf9e-42e0-be17-e2c3e1d2600dfoaf:name The Beatles;mo:membermo:ba550d0e-adac-4864-b88b-407cab5e76af;mo:membermo:4d5447d7-c61c-4120-ba1b-d7f471d385b9;mo:membermo:42a8f507-8412-4611-854f-926571049fa0;mo:membermo:300c4c73-33ac-4255-9d57-4e32627f5e13.dbpedia:The_Beatlesdbpedia-ont:origin dbpedia:Liverpool;dbpedia-ont:genre dbpedia:Rock_music;foaf:depiction .IntegrationData set Data setsame
    56. 56. Reasoning forLinked Data IntegrationEUCLID - Querying Linked Data 56mo:b10bbbfc-cf9e-42e0-be17-e2c3e1d2600dfoaf:name The Beatles;mo:membermo:ba550d0e-adac-4864-b88b-407cab5e76af;mo:membermo:4d5447d7-c61c-4120-ba1b-d7f471d385b9;mo:membermo:42a8f507-8412-4611-854f-926571049fa0;mo:membermo:300c4c73-33ac-4255-9d57-4e32627f5e13.dbpedia:The_Beatlesdbpedia-ont:origin dbpedia:Liverpool;dbpedia-ont:genre dbpedia:Rock_music;foaf:depiction .sameSELECT ?m ?g WHERE {dbpedia:The_Beatlesdbpedia-ont:genre ?g;mo:member ?m.}Query: ?m ?gmo:ba550d0e-adac-4864-b88b-407cab5e76afdbpedia:Rock_musicmo:4d5447d7-c61c-4120-ba1b-d7f471d385b9dbpedia:Rock_musicmo42a8f507-8412-4611-854f-926571049fa0;dbpedia:Rock_musicmo300c4c73-33ac-4255-9d57-4e32627f5e13dbpedia:Rock_musicResult set:
    57. 57. SPARQL 1.1:Entailment RegimesEUCLID - Querying Linked Data 57• SPARQL 1.0 was defined only for simple entailment(pattern matching )• SPARQL 1.1 is extended with entailment regimes otherthan simple entailment:– RDF entailment– RDFS entailment– D-Entailment– OWL RL entailment– OWL Full entailment– OWL 2 DL, EL, and QL entailment– RIF entailmentSource: http://www.w3.org/TR/rdf-mt/#RDFSRules
    58. 58. RDFSEUCLID - Querying Linked Data 58Resource Description Framework SchemaSemantic Web StackBerners-Lee (2006)Taxonomies and inferences
    59. 59. RDFS Entailment RegimesEUCLID - Querying Linked Data 59• Contains 13 entailment rules denominated rdfsi forinference over RDFS definitions*:– rdfs:Literal (rdfs1, rdfs13)– rdfs:domain (rdfs2), rdfs:range (rdfs3)– rdfs:Resource (rdfs4a, rdfs4, rdfs8)– rdfs:subPropertyOf (rdfs5, rdfs6, rdfs7, rdfs12)– rdfs:Class (rdfs8, rdfs10)– rdfs:subClassOf (rdfs9, rdfs10, rdfs11)– rdfs:ContainerMembershipProperty (rdfs12)– rdfs:Datatype (rdfs13)* Source: http://www.w3.org/TR/rdf-mt/#RDFSRules
    60. 60. rdfs2 – rdfs:domainEUCLID - Querying Linked Data 60dbpedia:The_Beatlesdbpedia:Paul_McCartneySELECT ?x WHERE {?x a mo:MusicGroup.}mo:member rdfs:domainmo:MusicGroup .?x ?xdbpedia:The_Beatles …mo:memberSchema: Query:Result set: Result set with inference:dbpedia:John_Lennondbpedia:George_Harrisondbpedia:Ringo_Starrmo:member mo:membermo:member
    61. 61. rdfs3 – rdfs:rangeEUCLID - Querying Linked Data 61dbpedia:The_Beatlesdbpedia:Paul_McCartneySELECT ?x WHERE {?x a foaf:Agent.}mo:member rdfs:rangefoaf:Agent .?x ?xdbpedia:Paul_McCartneydbpedia:John_Lennondbpedia:Ringo_Starrdbpedia:George_Harrison …dbpedia-ont:bandMemberSchema: Query:Result set: Result set with inference:dbpedia:John_Lennondbpedia:George_Harrisondbpedia:Ringo_Starrdbpedia-ont:bandMemberdbpedia-ont:bandMemberdbpedia-ont:bandMember
    62. 62. rdfs7 – rdfs:subPropertyOfEUCLID - Querying Linked Data 62dbpedia:Yesterdaydbpedia:Paul_McCartneySELECT ?x WHERE {dbpedia:Yesterday mo:performer ?x.}mo:singer rdfs:subPropertyOfmo:performer .?xdbpedia:John_Lennondbpedia:Ringo_Starrdbpedia:George_Harrison?xdbpedia:John_Lennondbpedia:Ringo_Starrdbpedia:George_Harrisondbpedia:Paul_McCartneymo:singerSchema: Query:Result set: Result set with inference:dbpedia:John_Lennondbpedia:George_Harrisondbpedia:Ringo_Starrmo:performer mo:performermo:performermo:performer
    63. 63. rdfs9 – rdfs:subClassOfEUCLID - Querying Linked Data 63dbpedia:The_BeatlesSELECT ?x WHERE {?x a mo:MusicArtist.}mo:MusicGroup rdfs:subClassOfmo:MusicArtist .?x ?xdbpedia:The_Beatles …Schema: Query:Result set: Result set with inference:mo:MusicArtistrdf:typemo:MusicGrouprdf:type
    64. 64. Inference from SchemaEUCLID - Querying Linked Data 64• Knowledge encoded in the schema leads to infer newfacts• This is also captured in the set of axiomatic triples,which provide basic meaning for all the vocabulary termsmo:MusicGroup rdfs:subClassOf mo:MusicArtist .mo:MusicGroup a rdfs:Class .mo:MusicArtist a rdfs:Class .Schema:Inferredfacts:rdfs:subClassOf rdfs:domain rdfs:Class .rdfs:subClassOf rdfs:range rdfs:Class .
    65. 65. RDFS:Lack of Consistency CheckEUCLID - Querying Linked Data 65• It is possible to infer facts that seem incorrect facts,but RDFS cannot prevent this:Schema: mo:member rdfs:domain mo:MusicGroup ;rdfs:range foaf:Agent .Existing :PaulMcCartney a :SoloMusicArtist ;facts: :member :TheBeatles .Inferred :PaulMcCartney a :MusicGroup .facts: No contradiction!:The mis-modeling isnot diagnosedrdfs2
    66. 66. • We might wish further inferences, but these arebeyond the entailment rules implemented by RDFSRDFS:Inference LimitationsEUCLID - Querying Linked Data 66foaf:knows rdfs:domain foaf:Person ;rdfs:range foaf:Person .foaf:made rdfs:domain foaf:Agent .:PaulMcCartney foaf:made :Yesterday ;foaf:knows :RingoStarr .:PaulMcCartney a foaf:Agent ;a foaf:Person .:RingoStarr a foaf:Person .Schema:Existingfact:Inferredfacts::Yesterday dc:creator :PaulMcCartney.:RingoStarr foaf:knows :PaulMcCartney .These inferences require OWL!NOTinferred:Cannot model withRDFS that ‘x knows y’implies ‘y knows x’Cannot model withRDFS that if ‘x makesy’ implies that ‘thecreator of y is x’
    67. 67. OWLEUCLID - Querying Linked Data 67Web Ontology LanguageSemantic Web StackBerners-Lee (2006)Ontologies and inferences
    68. 68. Introduction to OWLEUCLID - Querying Linked Data 68• Provides more ontological constructs and avoids some ofthe potential confusion in RDFS• OWL 2 is divided into sub-languages denominatedprofiles:– OWL 2 EL: Limited to basicclassification, but with polynomial-timereasoning– OWL 2 QL: Designed to be translatableto relational database querying– OWL 2 RL: Designed to be efficientlyimplementable in rule-based systems• Most triple stores concentrate on the use of RDFS with asubset of OWL features, called OWL-Horst or RDFS++More restrictivethan OWL DL
    69. 69. OWL PropertiesEUCLID - Querying Linked Data 69OWL distinguishes between two types of properties:• OWL ObjectProperties: resources as values• OWL DatatypeProperties: literals as values:plays rdf:type owl:ObjectProperty;rdfs:domain :Musician;rdfs:range :Instrument .:hasMembers rdf:type owl:DatatypeProperty;rdfs:domain :MusicGrouprdfs:range xsd:int .
    70. 70. PropertyAxiomsEUCLID - Querying Linked Data 70• Property axioms include those from RDF Schema• OWL allows for property equivalence. Example:EquivalentObjectProperties(dbpedia-ont:bandMember mo:member)dbpedia-ont:bandMember owl:equivalentProperty mo:member.≡dbpedia:The_Beatlesdbpedia:Paul_McCartneymo:memberdbpedia:John_Lennondbpedia:George_Harrisondbpedia:Ringo_Starrmo:membermo:membermo:memberSELECT ?x {dbpedia:The_Beatlesdbpedia-ont:bandMember ?x.}Query:?xResult set:?xdbpedia:Paul_McCartneydbpedia:John_Lennondbpedia:Ringo_Starrdbpedia:George_HarrisonResult set with inference:
    71. 71. PropertyAxiomsEUCLID - Querying Linked Data 71• Property axioms include those from RDF Schema• OWL allows for property equivalence. Example:EquivalentObjectProperties(dbpedia-ont:bandMember mo:member)dbpedia-ont:bandMember owl:equivalentProperty mo:member.• OWL allows for property disjointness. Example:DisjointObjectProperty(dbpedia-ont:length mo:duration)dbpedia-ont:length owl:propertyDisjointWith mo:duration.• There is no standard for implementing inconsistencyreports under SPARQL≡≡
    72. 72. PropertyAxioms (2)EUCLID - Querying Linked Data 72OWL allows the definition of property characteristics to infer newfacts relating to instances and their properties• Symmetry• Transitivity• Inverse• Functional• Inverse Functional
    73. 73. Property Axioms:SymmetryEUCLID - Querying Linked Data 73dbpedia:The_Beatlesdbpedia:Billy_Prestondbpedia:Plastic_Ono_Band :associatedMusicalArtista owl:SymmetricProperty .?genredbpedia:Plastic_Ono_Band?genredbpedia:Plastic_Ono_Banddbpedia:Billy_Preston:associatedMusicalArtistSchema:Result set: Result set with inference:SELECT ?x WHERE {dbpedia:The_Beatles:associatedMusicalArtist ?x.}Query::associatedMusicalArtist
    74. 74. Property Axioms:TransitivityEUCLID - Querying Linked Data 74:Rock:Heavy_metal:Black_metal:Punk_rockSELECT ?genre WHERE {:Rock :subgenre ?genre .}:subgenre a owl:TransitiveProperty .?genre:Heavy_metal:Punk_rock?genre:Heavy_metal:Punk_rock:Black_metal:subgenre :subgenre:subgenre :subgenreSchema:Query:Result set: Result set with inference:
    75. 75. Property Axioms:InverseEUCLID - Querying Linked Data 75SELECT ?x WHERE {?x mo:member_ofdbpedia:The_Beatles .}mo:member_of owl:inverseOf mo:member.?xdbpedia:John_Lennondbpedia:George_Harrison?xdbpedia:John_Lennondbpedia:George_Harrisondbpedia:Paul_McCartneydbpedia:Ringo_StarrSchema:Query:Result set: Result set with inference:dbpedia:The_Beatlesdbpedia:Paul_McCartneymo:member_ofdbpedia:John_Lennondbpedia:George_Harrisondbpedia:Ringo_Starrmo:membermo:member_ofmo:membermo:member_of mo:member_of
    76. 76. Example: Every artist primarily playsonly one musical instrumentmo:primary_instrument rdf:type owl:FunctionalProperty .dbpedia:Jimi_Hendrix mo:primary_instrument dbpedia:Electric_Guitar.dbpedia:Jimi_Hendrix mo:primary_instrument dbpedia:E-Guitar.Conclusion dbpedia:Electric_Guitarowl:sameAs dbpedia:E-Guitar .Property Axioms:FunctionalEUCLID - Querying Linked Data 76It refers to a property that can have only one (unique)value for each instancer2samer1
    77. 77. Example: Every recording has a unique ISRC(International Standard Recording Code)mo:isrc rdf:type owl:InverseFunctionalProperty .mo:21047249-7b3f-4651-acca-246669c081fd mo:isrc "GBAYE6300412" .dbpedia:She_Loves_You mo:isrc "GBAYE6300412" .Conclusion mo:21047249-7b3f-4651-acca-246669c081fdowl:sameAs :dbpedia:She_Loves_You .Property Axioms:Inverse FunctionalEUCLID - Querying Linked Data 77It is useful for specifying unique properties identifyingan individualr2samer1
    78. 78. Individual AxiomsEUCLID - Querying Linked Data 78OWL Individuals represent instances of classes. They are related totheir class by the rdf:type property• We can state that two individuals are the sameSameIndividual(<artist/ba550d0e-adac-4864-b88b-407cab5e76af#_> dbpedia:PaulMcCartney)<artist/ba550d0e-adac-4864-b88b-407cab5e76af#_> owl:sameAs dbpedia:PaulMcCartney .• We can state that two individuals are differentDifferentIndividuals(:TheBeatles_band :TheBeatles_TVseries):TheBeatles_band owl:differentFrom :TheBeatles_Tvseries .≡≡
    79. 79. Class AxiomsEUCLID - Querying Linked Data 79Axioms declare general statements about concepts which are usedin logical inference (reasoning). Class axioms:• Sub-class relationship (from RDF Schema)• Equivalent relationship: classes have the same individualsEquivalentClass(:Musician :MusicArtist):Musician owl:equivalentClass :MusicArtist .• Disjointness: classes have no shared individualsDisjointClasses(:SoloMusicArtist :MusicGroup):SoloMusicArtist owl:disjointWith :MusicGroup .≡≡
    80. 80. Class ConstructionEUCLID - Querying Linked Data 80• OWL classes are defined by the OWL term owl:Class• OWL classes can be subclassed as in RDFS:• OWL classes may be combined with class constructs tobuild new classesMusic ArtistArtist:MusicArtist rdfs:subClassOf :Artist .
    81. 81. Class Construction (2)EUCLID - Querying Linked Data 81These class constructs are available in OWL, not in RDFSThe class of female music artistsObjectIntersectionOf(:Female :MusicArtist)[a owl:Class;owl:intersectionOf(:Female :MusicArtist)]The class of music artistsObjectUnionOf(:SoloMusicArtist :MusicGroup)[a owl:Class;owl:unionOf(:SoloMusicArtist :MusicGroup)]Everything that’s not instrumental musicObjectComplementOf(:InstrumentalMusic)[a owl:Class;owl:complementOf(:InstrumentalMusic)]FemaleMusic ArtistSoloGroupInstrumental≡≡≡NOTE: Anonymous classes!
    82. 82. Naming Class ConstructionsEUCLID - Querying Linked Data 82• Direct naming can be achieved via owl:equivalentClass• This construction provides necessary and sufficient conditionsfor class membership• Class naming can be also achieved using rdfs:subClassOf,it provides a necessary but insufficient condition for classmembershipMusic ArtistSoloGroupEquivalentClass(:MusicArtistObjectUnionOf(:SoloMusicArtist:MusicGroup)):MusicArtist owl:equivalentClass[owl:unionOf (:SoloMusicArtist :MusicGroup)]≡
    83. 83. SummaryEUCLID - Querying Linked Data 83• Basic concepts: triple patterns, graph patterns, SPARQL endpoint ...• SPARQL Query:• Query forms: ASK, SELECT, DESCRIBE, CONSTRUCT• Query patterns: BGP, UNION, OPTIONAL, FILTER• Sequence modifiers: DISTINCT, REDUCED, ORDER BY, LIMIT, OFFSET• SPARQL 1.1 Update:• Data management: INSERT, DELETE; DELETE/INSERT• Graph management: LOAD, CLEAR, CREATE, DROP, COPY/MOVE/ADD• SPARQL Protocol: query operation, update operationQueryingLinkedDataIn this chapter we studied:
    84. 84. Summary (2)EUCLID - Querying Linked Data 84• Reasoning over Linked Data:• SPARQL 1.1 entailment regimes• RDFS: entailment regimes, lacks of consistency check, inferencelimitations• OWL: properties, property axioms(symmetry, transitivity, inverse, functional, inversefunctional), individual axioms, class axioms, classconstructions, naming classes …ReasoningoverLinkedDataIn this chapter we studied:
    85. 85. For exercises, quiz and further material visit our website:EUCLID - Providing Linked Data 85@euclid_project euclidproject euclidprojecthttp://www.euclid-project.euOther channels:eBook Course
    86. 86. Acknowledgements• Alexander Mikroyannidis• Alice Carpentier• Andreas Harth• Andreas Wagner• Andriy Nikolov• Barry Norton• Daniel M. Herzig• Elena Simperl• Günter Ladwig• Inga Shamkhalov• Jacek Kopecky• John Domingue
• Juan Sequeda• Kalina Bontcheva• Maria Maleshkova• Maria-Esther Vidal• Maribel Acosta• Michael Meier• Ning Li• Paul Mulholland• Peter Haase• Richard Power• Steffen Stadtmüller86
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×