Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology.

Slides:



Advertisements
Similar presentations
Chungnam National University DataBase System Lab
Advertisements

1 ICS-FORTH EU-NSF Semantic Web Workshop 3-5 Oct Christophides Vassilis Database Technology for the Semantic Web Vassilis Christophides Dimitris Plexousakis.
XML Data Management 8. XQuery Werner Nutt. Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be.
XQuery How to handle databases with the XML standard? Peter van Keeken Industrial trainee, Evitech 4 th period 2002.
XML to Relational Database Mapping
XML: Extensible Markup Language
Bottom-up Evaluation of XPath Queries Stephanie H. Li Zhiping Zou.
XML May 3 rd, XQuery Based on Quilt (which is based on XML-QL) Check out the W3C web site for the latest. XML Query data model –Ordered !
XML, XML Schema, Xpath and XQuery Slides collated from various sources, many from Dan Suciu at Univ. of Washington.
 Copyright 2010 Digital Enterprise Research Institute. All rights reserved. Digital Enterprise Research Institute Transforming between RDF.
TIMBER A Native XML Database Xiali He The Overview of the TIMBER System in University of Michigan.
1 XQuery Web and Database Management System. 2 XQuery XQuery is to XML what SQL is to database tables XQuery is designed to query XML data What is XQuery?
Paper by: A. Balmin, T. Eliaz, J. Hornibrook, L. Lim, G. M. Lohman, D. Simmen, M. Wang, C. Zhang Slides and Presentation By: Justin Weaver.
A Graphical Environment to Query XML Data with XQuery
Query Languages Aswin Yedlapalli. XML Query data model Document is viewed as a labeled tree with nodes Successors of node may be : - an ordered sequence.
2005rel-xml-ii1 The SilkRoute system  The system goals  Scenario, examples  View Forests  View forest and query composition  View forest efficient.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
1 COS 425: Database and Information Management Systems XML and information exchange.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
4/20/2017.
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
XML, CFMX CFML & SQL XML Kevin Penny, MMCP
Lecture 21 XML querying. 2 XSL (eXtensible Stylesheet Language) In HTML, default styling is built into browsers as tag set for HTML is predefined and.
Lecture 6 of Advanced Databases XML Schema, Querying & Transformation Instructor: Mr.Ahmed Al Astal.
TDDD43 XML and RDF Slides based on slides by Lena Strömbäck and Fang Wei-Kleiner 1.
IBM Research © 2005 IBM Corporation XJ: Robust XML Processing in Java™ Mukund Raghavachari, Rajesh Bordawekar, Michael Burke, and Igor Peshansky IBM T.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation An Introduction to XQuery.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
SPARQL Semantic Web - Spring 2008 Computer Engineering Department Sharif University of Technology.
1 SAMT’08 Semantic-driven multimedia retrieval with the MPEG Query Format Ruben Tous and Jaime Delgado Distributed Multimedia Applications Group (DMAG)
INTERPRETING IMPERATIVE PROGRAMMING LAGUAGES IN EXTENSIBLE STYLESHEET LANGUAGE TRANSFORMATIONS (XSLT) Authors: Ruhsan Onder Assoc.
XML as a Boxwood Data Structure Feng Zhou, John MacCormick, Lidong Zhou, Nick Murphy, Chandu Thekkath 8/20/04.
The main mathematical concepts that are used in this research are presented in this section. Definition 1: XML tree is composed of many subtrees of different.
Company LOGO OODB and XML Database Management Systems – Fall 2012 Matthew Moccaro.
Semantic web course – Computer Engineering Department – Sharif Univ. of Technology – Fall Querying on the Web: XQuery, RDQL, SparQL Semantic Web.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
1 XSLT An Introduction. 2 XSLT XSLT (extensible Stylesheet Language:Transformations) is a language primarily designed for transforming the structure of.
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Master Informatique 1 Semantic Technologies Part 7SPARQL 1.1 Werner Nutt.
Database Systems Part VII: XML Querying Software School of Hunan University
Keyword Searching Weighted Federated Search with Key Word in Context Date: 10/2/2008 Dan McCreary President Dan McCreary & Associates
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
XML query. introduction An XML document can represent almost anything, and users of an XML query language expect it to perform useful queries on whatever.
XML and Database.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
1 Typing XQuery WANG Zhen (Selina) Something about the Internship Group Name: PROTHEO, Inria, France Research: Rewriting and strategies, Constraints,
Ontology based e-Real Estate Agency Information System By Moein Mehrolhasani Bijan Zamanian cmpe 588.
Friday, September 4 th, 2009 The Systems Group at ETH Zurich XML and Databases Exercise Session 5 courtesy of Ghislain Fourny/ETH © Department of Computer.
This PowerPoint is based on slides from: Rajshekhar Sunderraman, Department of Computer Science Georgia State University.
An Effective SPARQL Support over Relational Database Jing Lu, Feng Cao, Li Ma, Yong Yu, Yue Pan SWDB-ODBIS 2007 SNU IDB Lab. Hyewon Lim July 30 th, 2009.
Grouping Robin Burke ECT 360. Outline Grouping: Sibling difference method Uniquifying in XPath Grouping: Muenchian method Generated ids Keys Moded Templates.
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
Lecture 23 XQuery 1.0 and XPath 2.0 Data Model. 2 Example 31.7 – User-Defined Function Function to return staff at a given branch. DEFINE FUNCTION staffAtBranch($bNo)
XML Databases. XML Like HTML –Tags –Fixed vocabulary of tags and fixed structure –Tags indicate formatting, not semantics Strict HTML – XHTML –Always.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
1 The XPath Language. 2 XPath Expressions Flexible notation for navigating around trees A basic technology that is widely used uniqueness and scope in.
Neo4j: GRAPH DATABASE 27 March, 2017
XML: Extensible Markup Language
Querying and Transforming XML Data
Database Processing with XML
Querying XML XQuery.
Querying XML XQuery.
Querying XML XPath.
Querying XML XPath.
2/18/2019.
XQuery Leonidas Fegaras.
Semantic Web Towards a Web of Knowledge - Outline
Introduction to XML IR XML Group.
Presentation transcript:

Querying on the Web: XQuery, RDQL, SparQL Semantic Web - Spring 2006 Computer Engineering Department Sharif University of Technology

2 Outline XQuery –Querying on XML Data RDQL –Querying on RDF Data SparQL –Another RDF query language (under development)

3 Requirements for an XML Query Language David Maier, W3C XML Query Requirements: Closedness: output must be XML Composability: wherever a set of XML elements is required, a subquery is allowed as well Can benefit from a schema, but should also be applicable without Retains the order of nodes Formal semantics

4 How Does One Design a Query Language? In most query languages, there are two aspects to a query: –Retrieving data (e.g., from … where … in SQL) –Creating output (e.g., select … in SQL) Retrieval consists of –Pattern matching (e.g., from … ) –Filtering (e.g., where … ) … although these cannot always be clearly distinguished

5 XQuery Principles A language for querying XML document. Data Model identical with the XPath data model –documents are ordered, labeled trees –nodes have identity –nodes can have simple or complex types (defined in XML Schema) XQuery can be used without schemas, but can be checked against DTDs and XML schemas XQuery is a functional language –no statements –evaluation of expressions

6 Sample data

7 {for $r in doc("recipes.xml")//recipe return $r/title} returns Beef Parmesan with Garlic Angel Hair Pasta Ricotta Pie … A Query over the Recipes Document

8 XPath {for $r in doc("recipes.xml")//recipe return $r/title} Query Features doc(String) returns input document Part to be returned as it is given{To be evaluated} Iteration $var - variables Sequence of results, one for each variable binding

9 Features: Summary The result is a new XML document A query consists of parts that are returned as is... and others that are evaluated (everything in {...} ) Calling the function doc( String ) returns an input document XPath is used to retrieve nodes sets and values Iteration over node sets: let binds a variable to all nodes in a node set Variables can be used in XPath expressions return returns a sequence of results, one for each binding of a variable

10 XPath is a Fragement of XQuery doc("recipes.xml")//recipe[1]/title returns Beef Parmesan with Garlic Angel Hair Pasta doc("recipes.xml")//recipe[position()<=3] /title returns Beef Parmesan with Garlic Angel Hair Pasta, Ricotta Pie, Linguine Pescadoro an element a list of elements

11 Beware: XPath Attributes doc("recipes.xml")//recipe[1]/ingredient[1] attribute name {"beef cube steak"} string(doc("recipes.xml")//recipe[1] "beef cube steak" a constructor for an attribute node a value of type string

12 XPath Attributes (cntd.) {string(doc("recipes.xml")//recipe[1] beef cube steak an element with string content

13 XPath Attributes (cntd.) {doc("recipes.xml")//recipe[1] an element with an attribute

14 XPath Attributes (cntd.) <first-ingredient oldName="{doc("recipes.xml")//recipe[1] Beef Beef An attribute is cast as a string

15 Iteration with the For-Clause Syntax: for $ var in xpath-expr Example: for $r in doc("recipes.xml")//recipe return string($r) The expression creates a list of bindings for a variable $ var If $ var occurs in an expression exp, then exp is evaluated for each binding For-clauses can be nested: for $r in doc("recipes.xml")//recipe for $v in doc("vegetables.xml")//vegetable return...

16 Nested For-clauses: Example {for $r in doc("recipes.xml")//recipe return {for $i in $r//ingredient return } } Returns my-recipes with titles as attributes and my-ingredients with names as text content

17 The Let Clause Syntax: let $ var := xpath-expr binds variable $ var to a list of nodes, with the nodes in document order does not iterate over the list allows one to keep intermediate results for reuse (not possible in SQL) Example: let $ooreps := doc("recipes.xml")//recipe oil"]

18 Let Clause: Example {let $ooreps := doc("recipes.xml")//recipe oil"] for $r in $ooreps return {$r/title/text()} {": "} } Calories of recipes with olive oil Note the implicit string concatenation

19 Let Clause: Example (cntd.) The query returns: Beef Parmesan: 1167 Linguine Pescadoro: 532

20 The Where Clause Syntax: where occurs before return clause similar to predicates in XPath comparisons on nodes: –" = " for node equality –" > " for document order Example: for $r in doc("recipes.xml")//recipe where oil" return...

21 Quantifiers Syntax: some / every $ var in satisfies $ var is bound to all nodes in Test succeeds if is true for some/every binding Note: if is empty, then some is false and all is true

22 Quantifiers (Example) Recipes that have some compound ingredient Recipes where every ingredient is non-compound for $r in doc("recipes.xml")//recipe where some $i in $r/ingredient satisfies $i/ingredient Return $r/title for $r in doc("recipes.xml")//recipe where every $i in $r/ingredient satisfies not($i/ingredient) Return $r/title

23 Element Fusion To every recipe, add the attribute calories! {let $rs := doc("recipes.xml")//recipe for $r in $rs return {$r/title} } an elementan attribute

24 Element Fusion (cntd.) The query result: Beef Parmesan with Garlic Angel Hair Pasta Ricotta Pie Linguine Pescadoro

25 Eliminating Duplicates The function distinct-values( Node Set ) –extracts the values of a sequence of nodes –creates a duplicate free sequence of values Note the coercion: nodes are cast as values! Example: let $rs := doc("recipes.xml")//recipe return yields "beef cube steak onion, sliced into thin rings...

26 Syntax: order by expr [ ascending | descending ] for $iname in order by $iname descending return string($iname) yields "whole peppercorns", "whole baby clams", "white sugar",... The Order By Clause

27 The Order By Clause (cntd.) The interpreter must be told whether the values should be regarded as numbers or as strings (alphanumerical sorting is default) for $r in $rs order by return $r/title Note: –The query returns titles... –but the ordering is according to calories, which do not appear in the output Not possible in SQL!

28 Grouping and Aggregation Aggregation functions count, sum, avg, min, max Example: The number of simple ingredients per recipe for $r in doc("recipes.xml")//recipe return {attribute {"title"} {$r/title/text()}} {count($r//ingredient[not(ingredient)])}

29 Grouping and Aggregation (cntd.) The query result: 11, 12, 15, 8, 30

Nested Aggregation The recipe with the maximal number of calories! let $rs := doc("recipes.xml")//recipe let $maxCal := for $r in $rs where = $maxCal return string($r/title) returns "Cailles en Sarcophages"

31 Running Queries with Galax Galax is an open-source implementation of XQuery ( –The main developers have taken part in the definition of XQuery

RDQL Querying on RDF data

33 Introduction RDF Data Query Language JDBC/ODBC friendly Simple: SELECT some information FROM somewhere WHERE this match AND these constraints USING these vocabularies

34 Example

35 Example q1 contains a query: SELECT ?x WHERE (?x,, "John Smith") For executing q1with a model m1.rdf: java jena.rdfquery --data m1.rdf --query q1 The outcome is: x =============================

36 Example Return all the resources that have property FN and the associated values: SELECT ?x, ?fname WHERE (?x,, ?fname) The outcome is: x | fname ================================================ | "John Smith" | "Sarah Jones" | "Matt Jones"

37 Example Return the first name of Jones: SELECT ?givenName WHERE (?y,, "Jones"), (?y,, ?givenName) The outcome is: givenName ========= "Matthew" "Sarah"

38 URI Prefixes : USING RDQL has a syntactic convenience that allows prefix strings to be defined in the USING clause : SELECT ?x WHERE (?x, vCard:FN, "John Smith") USING vCard FOR SELECT ?givenName WHERE (?y, vCard:Family, "Smith"), (?y, vCard:Given, ?givenName) USING vCard FOR

39 Filters RDQL has a syntactic convenience that allows prefix strings to be defined in the USING clause : SELECT ?resource WHERE (?resource, info:age, ?age) AND ?age >= 24 USING info FOR

40 Another Example SELECT ?title ?description ?orbit ?satellite ?sensor ?date FROM WHERE (?item ?title) (?item ?description) (?item ?orbit) (?item ?satellite) (?item ?sensor) (?item ?date) USING isc FOR dc FOR rdf FOR rdfs FOR

41 Implementations Jena – Sesame – RDFStore –

42 Limitation Does not take into account semantics of RDFS For example: ex:human rdfs:subClassOf ex:animal ex:student rdfs:subClassOf ex:human ex:john rdf:type ex:student Query: To which class does the resource John belong? Expected answer: ex:student, ex:human, ex:animal However, the query: SELECT ?x WHERE (, rdf:type, ?x) USING rdf FOR Yields only: Solution: Inference Engines

SparQL

44 Introduction A RDF query language currently under development by W3C Builds on previous RDF query languages such as rdfDB, RDQL, and SeRQL.

45 Example RDF

46 Example Simple Query: PREFIX foaf: SELECT ?url FROM WHERE { ?contributor foaf:name "Jon Foobar". ?contributor foaf:weblog ?url. }

47 Example (cont.) Optional block: PREFIX foaf: SELECT ?name ?depiction WHERE { ?person foaf:name ?name. OPTIONAL { ?person foaf:depiction ?depiction. } }

48 Example (cont.) Alternative matches: PREFIX foaf: PREFIX rdf: SELECT ?name ?mbox WHERE { ?person foaf:name ?name. { { ?person foaf:mbox ?mbox } UNION { ?person foaf:mbox_sha1sum ?mbox } } There are many other features in SparQL which is out of scope for this class. Refer to references for more information.

49 References A Programmer's Introduction to RDQL –