Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "RDF Query language The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer” Dean Allemang, Jim Hendler, “Semantic Web."— 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 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 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 4 Why RDF Query—understanding semantics Grigoris Antoniou David Billington A query for the names of all lecturers should return both Grigoris Antoniou and David Billington

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

6 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 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 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 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 –?w lit:wrote lit:KingLear. –lit:Shakespeare ?r lit:KingLear. –lit:Shakespeare lit:wrote ?p. –Who wrote KingLear? –What relationship did Shakespeare have to KingLear? –What did Shakespeare write?

10 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 11 Graph pattern {?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} }


Download ppt "RDF Query language The following slides are from Grigoris Antoniou, Frank van Harmelen, “A Semantic Web Primer” Dean Allemang, Jim Hendler, “Semantic Web."

Similar presentations


Ads by Google