1 / 46

CS 253: Topics in Database Systems: C4

CS 253: Topics in Database Systems: C4. Dr. Alexandra I. Cristea http://www.dcs.warwick.ac.uk/~acristea/. Previously we looked at: XML, and its query language(s) RDF Next: RDF query languages. RDF query languages. Proposals. SPARQL http://www.w3.org/TR/rdf-sparql-query/ RDQL

bertha
Download Presentation

CS 253: Topics in Database Systems: C4

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. CS 253: Topics in Database Systems: C4 Dr. Alexandra I. Cristea http://www.dcs.warwick.ac.uk/~acristea/

  2. Previously we looked at: • XML, and its query language(s) • RDF • Next: • RDF query languages

  3. RDF query languages

  4. Proposals • SPARQL • http://www.w3.org/TR/rdf-sparql-query/ • RDQL • http://www.w3.org/Submission/RDQL/ • RQL • http://139.91.183.30:9090/RDF/RQL/ • SeRQL • http://www.openrdf.org/doc/sesame/users/ch06.html • Triple: • http://triple.semanticweb.org/ • N3: • http://www.w3.org/DesignIssues/Notation3 • Comparison of languages: • http://www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query/rdfquery.pdf

  5. SeRQL

  6. Introduction SeRQL • "Sesame RDF Query Language", pronounced "circle“ • new RDF/RDFS query language • currently being developed by Aduna as part of Sesame. http://www.openrdf.org/ • It combines (best?) features of other (query) languages (RQL, RDQL, N-Triples, N3) and adds some of its own.

  7. Sesame • open source RDF framework with support for RDF Schema inferencing and querying. • Originally, it was developed by Aduna (then known as Aidministrator) as a research prototype for the EU research project On-To-Knowledge. • further developed and maintained by Aduna in cooperation with NLnet Foundation, developers from Ontotext, and a number of volunteer developers

  8. SeRQL's features • Graph transformation. • RDF Schema support. • XML Schema datatype support. • Expressive path expression syntax. • Optional path matching.

  9. SeRQL basic building blocks • RDF: • URIs, • literals and • variables URIs and literals • variables

  10. Variables • identified by names. • must start with a letter or an underscore ('_') and can be followed by zero or more letters, numbers, underscores, dashes ('-') or dots ('.'). • Examples: Var1 _var2 unwise.var-name_isnt-it • SeRQL keywords are not allowed to be used as variable names.

  11. (reserved) Keywords • Currently: select, construct, from, where, using, namespace, true, false, not, and, or, like, label, lang, datatype, null, isresource, isliteral, sort, in, union, intersect, minus, exists, forall, distinct, limit, offset. • case-insensitive, (unlike variable names).

  12. URIs • full URIs • abbreviated URIs (QNames)

  13. Full URIs • must be surrounded with "<" and ">". • Tend to be long (!!) • Examples: <http://www.openrdf.org/index.html> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <mailto:sesame@openrdf.org> <file:///C:\rdffiles\test.rdf>

  14. Abbreviated URIs (QNames) • Components: defined prefix (for the namespace) and a colon (“:”), then the URI part that is not a namespace • Examples: sesame:index.html rdf:type foaf:Person

  15. label Language tag datatype Literals • Parts: • “label”, • language tag, and • datatype • Examples: "foo" "foo"@en "<foo/>"^^http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral "<foo/>"^^rdf:XMLLiteral Optional, mutually exclusive

  16. Blank nodes • RDF has a notion of blank nodes. • nodes that are not labelled with a URI or literal. • Interpretation (): "there exists a node such that..." • Blank nodes have internal identifiers • Shortcut in SeRQL: _:bnode1 • Attention: problem of non-portability!!!

  17. Path expressions • expressions that match specific paths through an RDF graph • usually, triples = path expressions of length 1 • in SeRQL: arbitrary length

  18. Basic path expressions • Query: • persons who work for (companies that are) IT companies.

  19. Original (possible) RDF: <?xml version=“1.0”?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foo="http://www.mycompany.smthg/company#"> <rdf:Description about=“http://www.mycompany.smthg/company/Person”> <foo:worksFor> rdf:resource=“http://www.mycompany.smthg/company/Company” </foo:worksFor> </rdf:Description> <rdf:Description about=“http://www.mycompany.smthg/company/Company”> <rdf:type>rdf:resource=“http://www.mycompany.smthg/company/CompanySchema#ITCompany”</rdf:type> </rdf:Description> </rdf:RDF>

  20. Basic path expressions • Query: • persons who work for (companies that are) IT companies. {Person} foo:worksFor {Company} rdf:type {foo:ITCompany} <foo:worksFor> <rdf:type> Company Person <foo:ITCompany> Triple (length =1):

  21. Multiple Path Expressions • Separated with commas • Example: {Person} ex:worksFor {Company}, {Company} rdf:type {ex:ITCompany}

  22. Non-interesting nodes • Can be left empty • Examples: {Person} ex:worksFor {} rdf:type {ex:ITCompany} {Painting} ex:painted_by {} ex:name {"Picasso"}

  23. Path expression short cuts • Multi-value nodes • Branches • Reified statements

  24. Multi-valued nodes • Multiple objects: {subj1} pred1 {obj1, obj2, obj3} • Multiple subjects: {subj1, subj2, subj3} pred1 {obj1} • Condition: disjoint !!

  25. Branches {subj1} pred1 {obj1}; pred2 {obj2} Equivalent to: {subj1} pred1 {obj1}, {subj1} pred2 {obj2}

  26. Reified statements • { {reifSubj} reifPred {reifObj} } pred {obj} • Equivalent to: • {_Statement} rdf:type {rdf:Statement}, {_Statement} rdf:subject {reifSubj}, {_Statement} rdf:predicate {reifPred}, {_Statement} rdf:object {reifObj}, {_Statement} pred {obj}

  27. Optional Path Expressions {Person} ex:name {Name}; ex:age {Age}; [ex:email {EmailAddress}]

  28. Queries in SeRQL • Select queries: • returning a table of values, or a set of variable-value bindings. • SELECT, FROM, WHERE, LIMIT, OFFSET and USING NAMESPACE • Construct queries: • returns a true RDF graph • CONSTRUCT, FROM, WHERE, LIMIT, OFFSET and USING NAMESPACE

  29. Select queries • SELECT C FROM {C} rdf:type {rdfs:Class} • returns all URIs of classes • SELECT DISTINCT * FROM {Country1} ex:borders {} ex:borders {Country2} USING NAMESPACE ex =<http://example.org/things#>

  30. Construct queries • CONSTRUCT {Parent} ex:hasChild {Child} FROM {Child} ex:hasParent {Parent} USING NAMESPACE ex = <http://example.org/things#> • CONSTRUCT * FROM {SUB} rdfs:subClassOf {SUPER} • This query extracts all rdfs:subClassOf relations from an RDF graph.

  31. WHERE clause • Optional; • Specifies Boolean constraints SELECT Country FROM {Country} ex:population {Population} WHERE Population < "1000000"^^xsd:positiveInteger USING NAMESPACE ex = <http://example.org/things#>

  32. Nested WHERE clauses • Query 1 (normal WHERE-clause): SELECT Name, EmailAddress FROM {Person} foaf:name {Name}; [ex:email {EmailAddress}] WHERE EmailAddress LIKE "g*" • Query 2 (nested WHERE-clause): SELECT Name, EmailAddress FROM {Person} foaf:name {Name}; [ex:email {EmailAddress} WHERE EmailAddress LIKE "g*"] • at most one nested WHERE-clause per optional path expression, and at most one 'normal' WHERE-clause

  33. Results WHERE queries • Query 1 Name EmailAddress Giancarlo giancarlo@example.work • Query 2 (nested WHERE) Name EmailAddress Michael  Rubens  Giancarlo "giancarlo@example.work"

  34. LIKE operator SELECT Country FROM {Country} ex:name {Name} WHERE Name LIKE “netherlands" IGNORE CASE USING NAMESPACE ex = <http://example.org/things#>

  35. Built-in predicates • {X} serql:directSubClassOf {Y} • {X} serql:directSubPropertyOf {Y} • {X} serql:directType {Y}

  36. Set combinatory operations • Union • Intersect • Minus

  37. Union SELECT title FROM {book} dc10:title {title} UNION SELECT title FROM {book} dc11:title {title} USING NAMESPACE dc10 = <http://purl.org/dc/elements/1.0/>, dc11 = <http://purl.org/dc/elements/1.1/>

  38. Intersect SELECT creator FROM {album} dc10:creator {creator} INTERSECT SELECT creator FROM {album} dc11:creator {creator} USING NAMESPACE dc10 = <http://purl.org/dc/elements/1.0/>, dc11 = <http://purl.org/dc/elements/1.1/>

  39. Minus (difference) SELECT title FROM {album} dc10:title {title} MINUS SELECT title FROM {album} dc10:title {title}; dc10:creator {creator} WHERE creator like "Paul" USING NAMESPACE dc10 = <http://purl.org/dc/elements/1.0/>, dc11 = <http://purl.org/dc/elements/1.1/>

  40. NULL values • SELECT * • FROM {X} Y {Z} • WHERE isLiteral(Z) AND datatype(L) = NULL • to check that a literal doesn't have a datatype;

  41. Query Nesting • IN • ANY, ALL • EXISTS

  42. IN SELECT name FROM {} rdf:type {ex:Person}; ex:name {name} WHERE name IN ( SELECT n FROM {} rdf:type {ex:Author}; ex:name {n} ) USING NAMESPACE ex = http://example.org/things# • retrieve all names of Persons, but only those names that also appear as names of Authors.

  43. ANY, ALL SELECT highestValue FROM {node} ex:value {highestValue} WHERE highestValue >= ALL ( SELECT value FROM {} ex:value {value} ) USING NAMESPACE ex = <http://example.org/things#>

  44. EXISTS SELECT name, hobby FROM {} rdf:type {ex:Person}; ex:name {name}; ex:hobby {hobby} WHERE EXISTS ( SELECT n FROM {} rdf:type {ex:Author}; ex:name {n}; ex:authorOf {} WHERE n = name ) USING NAMESPACE ex = <http://example.org/things#>

  45. RDF Query Languages Conclusion • We have learned: • There is a high competition for providing The RDF query language • No standards as yet • We have looked in more details at one of them, SeRQL, as it is an implementers’ language paired with an existing RDF repository tool, Sesame • Many features in SeRQL remind us of SQL, thus learning threshold should be low

  46. Next: • OWL

More Related