SQL, Xquery, and SPARQL Xquery What’S Wrong with This Picture? SPARQL 2006-03-01 Copyright © 2006 Oracle Corp

SQL, Xquery, and SPARQL Xquery What’S Wrong with This Picture? SPARQL 2006-03-01 Copyright © 2006 Oracle Corp

SQL SQL, XQuery, and SPARQL XQuery What’s Wrong With This Picture? SPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 1 Jim Melton, Oracle Corp. SQLCo-chair: W3C XML Query WG Editor: XQuery F&O, XQueryX Editor: all parts of SQL standard Author:XQuery 5 SQL books, as well as “Querying XML” (all from Morgan Kaufmann Publishers) SPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 2 SQLGenesis of this Talk • Interested in Semantic Web, RDF, & OWL • Discovered existence of SPARQL • Employer implementing RDF/OWL • DirectedXQuery to make recommendation re: implementing SPARQL • Research into implications of and relationships between RDF/SPARQL, relational/SQL, andSPARQL XML/XQuery 2006-03-01 Copyright © 2006 Oracle Corp. 3 Query Languages: SQL SQL(SQL Query Language) • A language for querying collections of tuples: SELECT SALARY, HIRE_DATE FROM EMPS WHEREXQuery EMP_ID = 13954 EMP_ID NAME HIRE_DATE SALARY 13954 Joe 2000-04-14 48000 10335 Mary 1998-11-23 52000 ……… … 04182 BobSPARQL2005-02-10 21750 2006-03-01 Copyright © 2006 Oracle Corp. 4 Query Languages: XQuery SQL(XML Query) • A language for querying trees of XDM nodes: for $e in document(my_employees.xml) where $emp/emp/@emp-id = 13954 return $emp/emp/salary XQuery<employees> <emp> <emp> <emp> <emp> emp-id = 13954 ... ... ... <name> <hire-date> <salary> Joe 2000-04-14 48000SPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 5 Crossing Data Model SQL Boundaries • SQL/XML EMP_ID NAME HIRE_ SALARY DATE 13954 Joe 2000-04-14 48000 Publishing 10335 Mary 1998-11-23 52000 Functions ………XQuery… 04182 Bob 2005-02-10 21750 <employees> <emp> <emp> <emp> <emp> emp-id = 13954 ... ... ... <name> <hire-date> <salary> XMLTable Joe SPARQL2000-04-14 48000 2006-03-01 Copyright © 2006 Oracle Corp. 6 RDF: Collections of Tuples (RSQLesource Description Framework) • 3-tuples: subject, predicate, object emps:e13954 HR:name 'Joe' emps:e13954 HR:hire-date 2000-04-14 emps:e13954 HR:salary 48000 • RDF in a table: Subject Predicate Object XQueryemps:e13954 HR:name 'Joe' emps:e13954 HR:hire-date 2000-04-14 emps:e13954 HR:salary 48000 • Trivial SQL statement: SELECT object FROM RDFtable WHERE subject="emps:e13954"SPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 7 SQLRDF: Not Quite That Simple • RDF can indicate membership in classes (emps:e13954 rdf:type HR:employee) • RDF prefixes are shorthand for full URIs • RDF is a graph HR:emp XQueryrdf:type data model rdf:type HR:supervises emps:e10335 emps:e13954 HR:worksIn HR:dept HR:manages SPARQLdept:sales rdf:type 2006-03-01 Copyright © 2006 Oracle Corp. 8 OWL SQL(Web Ontology Language) • A particular vocabulary of RDF • Represents meanings of terms and relationships between terms: an ontology •OWL is RDF,XQuery but adds: – Relations between classes – Cardinality – Equality – More typing of and characteristics of properties – Enumerated classesSPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 9 SQLRDF vs The Relational Model • Relational – Flat, tabular, implicit typing (column definition) – Joins used to combine information from tables – Foreign keys: semantics and graph-like structure – Each table:XQuery many columns = many attributes of object •RDF – May be viewed as flat; explicit typing common – Explicit relationships via predicates – Inherent graph structure violates “flatness” – Triples ≈ E-R modelSPARQL (representable as a table w/2 columns) 2006-03-01 Copyright © 2006 Oracle Corp. 10 SQLRDF vs XDM •XDM – Tree-structured plus sequences of items – No support for explicit relationships (references) – No tuples,XQuery not limited by tuples •RDF – Network of objects; more general than trees – Relationships/references are the point of RDF – Triple nature createsSPARQL plethora of tiny data 2006-03-01 Copyright © 2006 Oracle Corp. 11 Query Languages: SPARQL (SPARQL Protocol And RDF SQLQuery Language) • Designed to query collections of triples… • …and to easily traverse relationships • VaguelyXQuery SQL-like syntax (SELECT, WHERE) • “Matches graph patterns” SELECT ?sal WHERE { emps:e13954SPARQL HR:salary ?sal } 2006-03-01 Copyright © 2006 Oracle Corp. 12 SQLSPARQL vs SQL • SPARQL SELECT ?sal WHERE { emps:e13954 HR:salary ?sal . } •SQL XQuery SELECT salary FROM employees WHERE emp_idSPARQL = 'e13954' 2006-03-01 Copyright © 2006 Oracle Corp. 13 SQLSPARQL vs SQL • SPARQL SELECT ?id, ?sal WHERE { ?id HR:salary ?sal } •SQL XQuery SELECT emp_id, salary FROM employees SPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 14 SQLSPARQL vs SQL • SPARQL SELECT ?hdate WHERE { ?id HR:salary ?sal . ?id HR:hire_date ?hdate . XQueryFILTER ?sal >= 21750 } •SQL SELECT hire_date FROM employees WHERE salarySPARQL >= 21750 2006-03-01 Copyright © 2006 Oracle Corp. 15 SQLSPARQL vs SQL • SPARQL SELECT ?hdate WHERE { ?id HR:salary ?sal . ?id HR:hire_date ?hdate . XQueryFILTER ?sal >= 21750 } •SQL SELECT v.hire_date FROM emp_vars AS v, emp_consts AS c WHERE v.salary >= 21750 AND v.emp_id SPARQL= c.emp_id 2006-03-01 Copyright © 2006 Oracle Corp. 16 SQL Conclusions • SQL: Great for finding data from tabular representations, can get complex when many tables are involved in a given query • XQuery: Great for finding data in tree representations, can get complexXQuery when many relationships have to be traversed • SPARQL: Good pattern matching paradigm, especially when relationships have to be used to answer a query • Surprising conclusion: SPARQL can be translated to SQL and possiblySPARQL to XQuery! 2006-03-01 Copyright © 2006 Oracle Corp. 17 SQL XQuery SPARQL 2006-03-01 Copyright © 2006 Oracle Corp. 18.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us