1 / 12

RDF Query language

RDF Query language. The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer” Dean Allemang, Jim Hendler, “Semantic Web for the working ontologist”. Lecture outline. Ontology Syntax of RDF and RDFS Basic Ideas of RDF Three representations of RDF

uttara
Télécharger la présentation

RDF Query language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RDF Query language The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer” Dean Allemang, Jim Hendler, “Semantic Web for the working ontologist”

  2. Lecture outline • Ontology • Syntax of RDF and RDFS • Basic Ideas of RDF • Three representations of RDF • Basic Concepts of RDF Schema • Τhe Language of RDF Schema • Axiomatic Semantics for RDF and RDFS • Applications of RDF and RDFS • Querying of RDF/RDFS Documents The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer”

  3. Why RDF Query language—different XML representation • There are XML query languages, such as XQuery • XML at a lower level of abstraction than RDF • There are various ways of syntactically representing an RDF statement in XML • Thus we would require several XQuery queries, e.g. • //uni:lecturer/uni:title if uni:title is an element • //uni:lecturer/@uni:title if uni:title is an attribute • Both XML representations equivalent!

  4. Why RDF Query—understanding semantics <uni:lecturer rdf:ID="949352"> <uni:name>Grigoris Antoniou</uni:name> </uni:lecturer> <uni:professor rdf:ID="949318"> <uni:name>David Billington</uni:name> </uni:professor> <rdfs:Class rdf:about="#professor"> <rdfs:subClassOf rdf:resource="#lecturer"/> </rdfs:Class> • A query for the names of all lecturers should return both Grigoris Antoniou and David Billington

  5. RDF query languages • All have a SQL like syntax • SPARQL • became W3C recommendation in 2008. • RQL • …

  6. Using select-from-where • As in SQL • SELECT: specifies the projection operation, i.e., the number and order of retrieved data • FROM: specifies the data source from which to query; it is optional. • WHERE: imposes constraints on possible solutions • Retrieve all phone numbers of staff members: SELECT ?X ?Y WHERE {?X phone ?Y. } • Here X and Y are variables, and ?X phone ?Y represents a resource-property-value triple

  7. Retrieve all lecturers and their phone numbers: SELECT ?X ?Y WHERE {?X rdf:type lecturer. ?X phone ?Y. } SELECT ?X ?Y WHERE {?X rdf:type lecturer; phone ?Y. }

  8. Triple representation lit:Shakespeare lit:wrote lit:AsYouLikeIt; lit:wrote lit:Twel fthNight; lit:wrote lit:KingLear; lit:wrote lit:LovesLaboursLost ; lit:wrote lit:Hamlet; lit:wrote lit:TheTempest; lit:wrote lit:WintersTale; lit:wrote lit:HenryV; lit:wrote lit:MeasureForMeasure; lit:wrote lit:Othello; bio: livedIn geo: Stratford. bio: AnneHathaway bio: married lit:Shakespeare. geo: Stratford geo:isIn geo:England. geo: Scotland geo:partOf geo:UK. geo: England geo:partOf geo:UK. geo: Wales geo:partOf geo:UK. geo: NorthernIreland geo: partOf geo:UK. geo: ChannelIslands geo: part Of geo: UK. geo: IsleOfMan geo: partOf geo: UK.

  9. Triple pattern • Triple pattern is the basic building block of SPARQL • Similar to triple • Can have variables in place of resources • Same variable indicates the same resource ?wlit:wrotelit:KingLear. lit:Shakespeare ?rlit:KingLear. lit:Shakespearelit:wrote ?p. • Who wrote KingLear? • What relationship did Shakespeare have to KingLear? • What did Shakespeare write?

  10. Graph pattern • List of triple pattern enclosed in braces {?person bio: livedIn ?place. ?place geo: isIn geo:England. ?person lit:wrote lit:KingLear. } • Result ?person=Shakespeare ?place=Stratford

  11. {?person bio:married ?s . ?person lit:wrote lit:KingLear. } Result No result Solution bio:married owl:inverseOf bio:married . Another solution { {{?spouse1 bio:married ?spouse2} UNION { ?spouse2 bio:married ?spouse1} } { ?spouse1 lit:wrote lit:KingLear} } Graph pattern

  12. There are SPARQL query interfaces, e.g., • http://dbpedia.org/sparql • You can query dbpedia, e.g., select ?person where {?person <http://www.w3.org/2000/01/rdf-schema#label> "Steve"@en } • The result is • person • http://dbpedia.org/resource/Steve • http://dbpedia.org/class/yago/SteveMcMichael • http://dbpedia.org/class/yago/Steve,TheFirst • …

More Related