Big Data Exercises. Fall 2016 Week 9 ETH Zurich

Size: px
Start display at page:

Download "Big Data Exercises. Fall 2016 Week 9 ETH Zurich"

Transcription

1 Big Data Exercises Fall 2016 Week 9 ETH Zurich Introduction This exercise will cover XQuery. You will be using oxygen ( AN XML/JSON development IDE, in order to do this exercise. You should have received a license key for it by mail. Before starting, make sure oxygen is installed and working on your computer. Download the XML/XSD files book_catalogue.xml ( export=download&id=0b_c6n15v_sc7mmlscmfdewlkdws), airport-flight-passenger.xml ( airport-flightpassenger.xsd ( in order to complete the exercise. 1. XQuery Basics FLWOR For - Iterates over a sequence of nodes. Let - Binds a sequence to a variable. Where - Filters the nodes / specifies criteria for the result. Order by - Specifies sort order. Return - Specifies what need to be returned. Questions Run the following queries on book_catalogue.xml using oxygen: 1. Find book titles ordered lexicographically where book price is greater than Find books written in English which belong to category "CHILDREN" ordered by the year of publication. 3. Find books ordered by categories which are published after 2010 and costs less than Find all authors who have written books in the "BUSINESS" category before 2014 and sort their names lexicographically.

2 Solutions 1. for $x in doc("book_catalogue.xml")//book where $x/price>15 order by $x/title return $x/title Instead of using the where clause, we can also select books by their price in the xpath expression: for $x in doc("book_catalogue.xml")//book[price>15] order by $x/title return $x/title for $x in doc("book_catalogue.xml")//book where and order by $x/year return $x for $x in doc("book_catalogue.xml")//book where $x/year>2010 and $x/price<10 order by return $x for $x in doc("book_catalogue.xml")//book where $x/year<2014 and order by $x/author return $x/author Above query returns authors that have written several books multiple times. We can avoid this by first creating a list of xs:string of the names of the authors we are interested in and then select the corresponding author nodes, taking the first node for each name: let $doc := doc("book_catalogue.xml") let $books := $doc//book[year < 2014 let $authors := $doc//author[data() = $books//author] for $a in distinct-values($authors) order by $a return ($authors[data() = $a])[1]

3 Conditional Expressions If-Then-Else expressions are allowed in XQuery. Question Run the following query on book_catalogue.xml using oxygen: 1. List all the book titles. If the book belongs to category CHILDREN, put the title within <child></child> tag. Else put the title within <adult></adult> tag. Solution for $x in doc("book_catalogue.xml")//book return if then <child>{data($x/title)}</child> else <adult>{data($x/title)}</adult> 2. Namespaces in XQuery Consider the following document: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE eth SYSTEM "eth.dtd"> <eth xmlns=" xmlns:db=" date=" " db:date=" "> <date> </date> <president number="1">empty</president> <Rektor>Name 2</Rektor> </eth>

4 Question Correct the following XQuery expressions so that they refer to the correct namespace, in order to determine the value of the date sub-element and of the two date attributes: 1. /eth/date 2. Hint: you can bind a prefix pre to a URI ( with the following prolog declaration: declare namespace pre = " ( You can then use the prefix in path expressions. Solution To refer to the child element: declare namespace def = " /def:eth/def:date To refer to the date attribute in no namespace: declare namespace def = " /def:eth/@date To refer to the date attribute which in the dbisns namespace: declare namespace def = " declare namespace dbisns =" /def:eth/@dbisns:date Note that the expressions that query the attributes seem "not to work" in oxygen. We get the message "Your query returned an empty sequence." This is a missleading message. Actually, the query returns an attribute -- outside of any element! While this can perfectly exists in XQuery, (our version of) oxygen seems unable to display it. You can do the following to get the value of the attribute: declare namespace def = " /def:eth/@date/data()

5 3. XQuery Comparison Operators General comparison operators: =,!=, <, <=, >, >= Value comparison operators: eq, ne, lt, le, gt, ge The value comparison operators (eq, lt, etc.) are designed to compare single values (i.e. sequences of one value each). The "general comparison" operators (=, <, etc.) are designed to compare sequences of more than one values. "foo" eq ("foo","bar") throws an error. "foo" = ("foo","bar") returns true. With a general comparison operator, the expression will return true if any of the items on the left compare successfully with any of the items on the right. This is sometimes called "existential quantification." Questions 1. Find a variable binding for $x so that $x=1 and $x=2. Can one infer that, in XQuery, 1=2? 2. Find variable bindings for $x, $y and $z so that $x > $y and $y > $z, but $x > $z is not true. 3. Find a variable binding for $x so that neither $x eq $x nor $x = $x is true. Explain why. Solutions $x := (1,2) (1,2) = 1 (1,2) = 2 = is not transitive, so one can not infer 1=2. $x := 1, $y := (0, 3), $y := 2 1 > (0,3) and (0,3) > 2 but 1 > 2 is false. > is not transitive either. $x := () because () eq () returns () and () = () returns false

6 4. Atomization and Effective Boolean Value Atomization Atomization is the process of extracting the typed value of an item. This process is implied under certain circumstances. Some of the XQuery operators, such as arithmetic and comparison operators, depend on this process. For example, when you apply arithmetic operators directly to nodes, the typed value of a node is first retrieved by implicitly invoking the data function. This passes the atomic value as an operand to the arithmetic operator. Question Try to guess the outcome of the following XQuery expression: fn:sum( for $x in doc("book_catalogue.xml")//book where $x/@category eq "BUSINESS" return fn:sum($x/price) ) Solution Returns the total price of all books in the BUSINESS category. Note that the atomization in this case happens during the call to the inner fn:sum() and then the outer fn:sum() actually sums up the values. This makes the inner fn:sum() redundant. Instead, the return statement could return the sequence of elements without calling the inner fn:sum() in which case atomization as well as the summation will occur at the outer fn:sum(). Effective Boolean Value The effective Boolean value (EBV) of a sequence is computed implicitly during the processing of expressions that require Boolean values. Question Find the EBV (true/false) for the following descriptions of values: 1. An empty sequence 2. A sequence whose first item is a node 3. A single value of type xs:boolean 4. A single value of type xs:string 5. A single value of any numeric type

7 Solutions 1. false 2. true 3. false - if the xs:boolean value is false; true - if the xs:boolean value is true 4. false - if the length of the value is zero; true - if the length if the value is greater than zero 5. false - if the value is NaN or is numerically equal to zero; true - if the value is not numerically equal to zero 5. XQuery Functions XQuery is built on XPath expressions. XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. Here is the link ( to the documentation. A call to a function can appear where an expression may appear. Examples: In an element: for $x in doc("book_catalogue.xml")/bookstore/book where $x/@category="children" return <name>{upper-case($x/title)}</name> The above XQuery expression returns all books in the CHILDREN category in upper case. In the predicate of a path expression: for $x in doc("book_catalogue.xml")/bookstore/book[substring(title,1,4)='alg o'] return $x/title The above XQuery expression returns title elements for the books whose titles begin with "ÂAlgo". If you cannot find the XQuery function you need, you can write your own:

8 declare function prefix:function_name($parameter as datatype) as returndatatype {...function code here... }; Use the declare function keyword The name of the function must be prefixed The data type of the parameters are mostly the same as the data types defined in XML Schema The body of the function must be surrounded by curly braces Question Consider that the prices of books in the book_catalogue.xml file are given in USD. Find the price of the book titled "If Animals Kissed Good Night" in Euros (consider 1USD = 0.92EUR). Write a function that takes as input the price in USD and gives as output the price in EUR. Solution declare function local:convertprice($p as xs:decimal?) as xs:decimal? { $p * 0.92 }; for $x in doc("book_catalogue.xml")/bookstore/book[title='if Animals Kissed Good Night'] return <conv>{local:convertprice($x/price)}</conv> Note that use of xs:decimal? here is not necessary and instead we could use xs:decimal as well. But in cases where we need to handle empty sequences as input or output, xs:decimal? can be necessary. Note that book_catalogue.xml is not validated against a schema. In the next section you will run XQuery expressions on XML document validated against a schema.

9 6. More XQuery Expressions Consider the XML document airport-flight-passenger.xml validated against airport-flight-passenger.xsd distributed together with this exercise (download links in Introduction section). Write the XQuery expressions for solving the following problems. Your results should be well-formed XML. 1. Give the list of direct flights on which have "North Pole" (airport name) as the source airport. 2. Retrieve the busiest airport on (based on the number of departures and arrivals). 3. Identify all the flight destinations of Passenger "Santa Claus". 4. Consider the case of combined flights (one or more intermediate stops). As an example, flying from London to Zurich on might mean taking two separate flights: London-Amsterdam and Amsterdam-Zurich, both on the same date. Retrieve all flight possibilities from "North pole" to "South pole" on with one or two intermediate stops.

10 Solutions <Flights> { let $root := doc("airport-flight-passenger.xml") for $a in $root//airport[name/text() eq 'North Pole'] return $root//flight[(source eq $a/@airid) and (date/text() eq ' ')] } </Flights> 2. We first count the number of inbound and outbound flights for each airport. Then we order the airports based on these counts in descending order. Finally we find the maximum count and the airport(s) corresponding to this maximum count. <BusiestAirports> { let $doc := doc("airport-flight-passenger.xml") let $results := for $a in $doc//airport let $c as xs:integer := count($doc//flight[source eq $a/@airid or destination eq $a/@air Id]) order by $c descending, $a/name ascending return <result> {$a} <count>{$c}</count> </result> let $maxcount := max($results//count) return $results[xs:integer(count) eq $maxcount]/airport } </BusiestAirports> 3. We perform a join between passengers and reservations for Santa Claus. Then we look for the destination of each flight in the reservations, and retrieve the airport with the corresponding code. Finally, we make the list of airports unique and format the result.

11 <destinations> { let $doc := doc("airport-flight-passenger.xml") let $dest := for $p in $doc//passenger[name eq 'Santa Claus'], $r in $doc//reservation where $r/passref eq $p/passportnumber ion return eq $doc//flight[$r/flightref ]/name for $d in distinct-values($dest) return <destination>{$d}</destination> } </destinations> We can achieve the same effect by a sequence of let clauses: <destinations> { let $doc := doc("airport-flight-passenger.xml") let $passref := $doc//passenger[name eq 'Santa Claus']/passportnumber let $flightref := $doc//reservation[passref = $passref]/flightref let $destid := $doc//flight[@flightid = $flightref]/destination for $destination in $doc//airport[@airid = $destid]/name/text() return <destination>{$destination}</destination> } </destinations> 4. We perform joins between flights and append connections with one stop to connections with two stops.

12 let $doc := doc("airport-flight-passenger.xml") return <Possibilities> { for $f1 in $doc//flight[source eq 'NPL'], $f2 in $doc//flight[destination eq 'SPL'] where $f1/destination eq $f2/source and $f1/arrival lt $f2/departure and $f1/seats > 0 and $f2/seats > 0 return <OneIntermediateStop>{$f1}{$f2}</OneIntermediateStop>, for $f1 in $doc//flight[source eq 'NPL'], $f3 in $doc//flight[destination eq 'SPL'], $f2 in $doc//flight where $f1/destination eq $f2/source and $f2/destination eq $f3/source and $f1/arrival lt $f2/departure and $f2/arrival lt $f3/departure and $f1/seats > 0 and $f2/seats > 0 and $f3/seats > 0 return <TwoIntermediateStops>{$f1}{$f2}{$f3}</TwoIntermediateStops> } </Possibilities> 7. Analogy with SQL Have you noticed that the XQuery FLWOR expressions are similar to SQL SELECT statements? Of course, the for expression in XQuery identifies XML nodes while the FROM clause in SQL identifies tables from which rows are chosen. But this does not restrict us from trying to map the sub-expressions of XQuery FLWOR with the analogous syntax elements of SQL's select. Question Find the SQL syntax elements for the following XQuery expressions: for, where, order by, return. Solutions 1. FROM clause 2. WHERE clause 3. ORDER BY clause 4. SELECT clause

Big Data 10. Querying

Big Data 10. Querying Ghislain Fourny Big Data 10. Querying pinkyone / 123RF Stock Photo 1 Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

Big Data 12. Querying

Big Data 12. Querying Ghislain Fourny Big Data 12. Querying pinkyone / 123RF Stock Photo Declarative Languages What vs. How 2 Functional Languages for let order by if + any else = then every while where return exit with Expression

More information

XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau

XML Query Languages. Yanlei Diao UMass Amherst April 22, Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau XML Query Languages Yanlei Diao UMass Amherst April 22, 2008 Slide content courtesy of Ramakrishnan & Gehrke, Donald Kossmann, and Gerome Miklau 1 Querying XML How do you query a directed graph? a tree?

More information

Solution Sheet 5 XML Data Models and XQuery

Solution Sheet 5 XML Data Models and XQuery The Systems Group at ETH Zurich Big Data Fall Semester 2012 Prof. Dr. Donald Kossmann Prof. Dr. Nesime Tatbul Assistants: Martin Kaufmann Besmira Nushi 07.12.2012 Solution Sheet 5 XML Data Models and XQuery

More information

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1

XQuery. Leonidas Fegaras University of Texas at Arlington. Web Databases and XML L7: XQuery 1 XQuery Leonidas Fegaras University of Texas at Arlington Web Databases and XML L7: XQuery 1 XQuery Influenced by SQL Based on XPath Purely functional language may access elements from documents, may construct

More information

The Systems Group at ETH Zurich. XML and Databases Exercise Session 12. courtesy of Ghislain Fourny. Department of Computer Science ETH Zürich

The Systems Group at ETH Zurich. XML and Databases Exercise Session 12. courtesy of Ghislain Fourny. Department of Computer Science ETH Zürich ETH Zürich XML and Databases Exercise Session 12 The Systems Group at ETH Zurich courtesy of Ghislain Fourny Where we are: XQuery Implementation The problem we are solving today Square peg Round hole The

More information

Advanced Database Technologies XQuery

Advanced Database Technologies XQuery Advanced Database Technologies XQuery Christian Grün Database & Information Systems Group Introduction What is XQuery? query language (more than a) counterpart to SQL functional language general purpose

More information

Progress Report on XQuery

Progress Report on XQuery Progress Report on XQuery Don Chamberlin Almaden Research Center May 24, 2002 History Dec. '98: W3C sponsors workshop on XML Query Oct. '99: W3C charters XML Query working group Chair: Paul Cotton About

More information

Information Systems. XQuery. Nikolaj Popov

Information Systems. XQuery. Nikolaj Popov Information Systems XQuery Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at What Is XQuery The purpose of XQuery is to provide

More information

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model.

XML. Semi-structured data (SSD) SSD Graphs. SSD Examples. Schemas for SSD. More flexible data model than the relational model. Semi-structured data (SSD) XML Semistructured data XML, DTD, (XMLSchema) XPath, XQuery More flexible data model than the relational model. Think of an object structure, but with the type of each object

More information

Query Languages for XML

Query Languages for XML Query Languages for XML XPath XQuery 1 The XPath/XQuery Data Model Corresponding to the fundamental relation of the relational model is: sequence of items. An item is either: 1. A primitive value, e.g.,

More information

Navigating Input Documents Using Paths4

Navigating Input Documents Using Paths4 Chapter 4 CHAPTER 4 Navigating Input Documents Using Paths4 Path expressions are used to navigate input documents to select elements and attributes of interest. This chapter explains how to use path expressions

More information

XML and Semi-structured Data

XML and Semi-structured Data XML and Semi-structured Data Krzysztof Trawiński Winter Semester 2008 slides 1/27 Outline 1. Introduction 2. Usage & Design 3. Expressions 3.1 Xpath 3.2 Datatypes 3.3 FLWOR 4. Functions 5. Summary 6. Questions

More information

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar..

Introduction to XQuery. Overview. Basic Principles. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. .. Fall 2007 CSC 560: Management of XML Data Alexander Dekhtyar.. Overview Introduction to XQuery XQuery is an XML query language. It became a World Wide Web Consortium Recommendation in January 2007,

More information

Author: Irena Holubová Lecturer: Martin Svoboda

Author: Irena Holubová Lecturer: Martin Svoboda A7B36XML, AD7B36XML XML Technologies Lecture 4 XPath, SQL/XML 24. 3. 2017 Author: Irena Holubová Lecturer: Martin Svoboda http://www.ksi.mff.cuni.cz/~svoboda/courses/2016-2-a7b36xml/ Lecture Outline XPath

More information

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while

One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while 1 One of the main selling points of a database engine is the ability to make declarative queries---like SQL---that specify what should be done while leaving the engine to choose the best way of fulfilling

More information

8/1/2016. XSL stands for EXtensible Stylesheet Language. CSS = Style Sheets for HTML XSL = Style Sheets for XML. XSL consists of four parts:

8/1/2016. XSL stands for EXtensible Stylesheet Language. CSS = Style Sheets for HTML XSL = Style Sheets for XML. XSL consists of four parts: XSL stands for EXtensible Stylesheet Language. CSS = Style Sheets for HTML XSL = Style Sheets for XML http://www.w3schools.com/xsl/ kasunkosala@yahoo.com 1 2 XSL consists of four parts: XSLT - a language

More information

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data

Pre-Discussion. XQuery: An XML Query Language. Outline. 1. The story, in brief is. Other query languages. XML vs. Relational Data Pre-Discussion XQuery: An XML Query Language D. Chamberlin After the presentation, we will evaluate XQuery. During the presentation, think about consequences of the design decisions on the usability of

More information

XML. Document Type Definitions. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta

XML. Document Type Definitions. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta XML Document Type Definitions 1 XML XML stands for extensible Markup Language. XML was designed to describe data. XML has come into common use for the interchange of data over the Internet. 2 Well-Formed

More information

Parte IV: XPATH. Prof. Riccardo Torlone

Parte IV: XPATH. Prof. Riccardo Torlone BASI DI DATI II 2 modulo Parte IV: XPATH Prof. Riccardo Torlone Università Roma Tre Outline Location steps and paths Typical locations paths Abbreviations General expressions Riccardo Torlone: Basi di

More information

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views 1. (4 points) Of the following statements, identify all that hold about architecture. A. DoDAF specifies a number of views to capture different aspects of a system being modeled Solution: A is true: B.

More information

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018

XPath and XQuery. Introduction to Databases CompSci 316 Fall 2018 XPath and XQuery Introduction to Databases CompSci 316 Fall 2018 2 Announcements (Tue. Oct. 23) Homework #3 due in two weeks Project milestone #1 feedback : we are a bit behind, but will definitely release

More information

Big Data 9. Data Models

Big Data 9. Data Models Ghislain Fourny Big Data 9. Data Models pinkyone / 123RF Stock Photo 1 Syntax vs. Data Models Physical view Syntax this is text. 2 Syntax vs. Data Models a Logical view

More information

BASI DI DATI II 2 modulo

BASI DI DATI II 2 modulo BASI DI DATI II 2 modulo COMPLMNTI DI BASI DI DATI Parte IV: XPATH Prof. Riccardo Torlone Università Roma Tre Outline Location steps and paths Typical locations paths Abbreviations General expressions

More information

Database Management

Database Management Database Management - 2011 Model Answers 1. a. A data model should comprise a structural part, an integrity part and a manipulative part. The relational model provides standard definitions for all three

More information

Information Systems (Informationssysteme)

Information Systems (Informationssysteme) Information Systems (Informationssysteme) Jens Teubner, TU Dortmund jens.teubner@cs.tu-dortmund.de Summer 2013 c Jens Teubner Information Systems Summer 2013 1 Part IX XML Processing c Jens Teubner Information

More information

Visual C# 2012 How to Program by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d.

Visual C# 2012 How to Program by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d. Visual C# 2012 How to Program 1 99 2-20 14 by Pe ars on Ed uc ati on, Inc. All Ri ght s Re ser ve d. 1992-2014 by Pearson Education, Inc. All 1992-2014 by Pearson Education, Inc. All Although commonly

More information

SQL Data Querying and Views

SQL Data Querying and Views Course A7B36DBS: Database Systems Lecture 04: SQL Data Querying and Views Martin Svoboda Faculty of Electrical Engineering, Czech Technical University in Prague Outline SQL Data manipulation SELECT queries

More information

XQuery. Announcements (March 21) XQuery. CPS 216 Advanced Database Systems

XQuery. Announcements (March 21) XQuery. CPS 216 Advanced Database Systems XQuery CPS 216 Advanced Database Systems Announcements (March 21) 2 Midterm has been graded Homework #3 will be assigned next Tuesday Reading assignment due next Wednesday XML processing in Lore (VLDB

More information

Outline of this part (I) Part IV. Querying XML Documents. Querying XML Documents. Outline of this part (II)

Outline of this part (I) Part IV. Querying XML Documents. Querying XML Documents. Outline of this part (II) Outline of this part (I) Part IV Querying XML Documents Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2007/08 164 8 XPath Navigational access to XML documents Overview Context Location steps Navigation

More information

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9

XML databases. Jan Chomicki. University at Buffalo. Jan Chomicki (University at Buffalo) XML databases 1 / 9 XML databases Jan Chomicki University at Buffalo Jan Chomicki (University at Buffalo) XML databases 1 / 9 Outline 1 XML data model 2 XPath 3 XQuery Jan Chomicki (University at Buffalo) XML databases 2

More information

Anders Møller & Michael I. Schwartzbach 2006 Addison-Wesley

Anders Møller & Michael I. Schwartzbach 2006 Addison-Wesley Anders Møller & Michael I. Schwartzbach 2006 Addison-Wesley Location steps and paths Typical locations paths Abbreviations General expressions 2 Flexible notation for navigating around trees A basic technology

More information

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET

Burrows & Langford Appendix D page 1 Learning Programming Using VISUAL BASIC.NET Burrows & Langford Appendix D page 1 APPENDIX D XSLT XSLT is a programming language defined by the World Wide Web Consortium, W3C (http://www.w3.org/tr/xslt), that provides the mechanism to transform a

More information

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1 Slide 27-1 Chapter 27 XML: Extensible Markup Language Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree) Data Model. XML Documents, DTD, and XML Schema.

More information

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4

SQL: Data Querying. B0B36DBS, BD6B36DBS: Database Systems. h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4 B0B36DBS, BD6B36DBS: Database Systems h p://www.ksi.m.cuni.cz/~svoboda/courses/172-b0b36dbs/ Lecture 4 SQL: Data Querying Mar n Svoboda mar n.svoboda@fel.cvut.cz 20. 3. 2018 Czech Technical University

More information

XML Technologies. Doc. RNDr. Irena Holubova, Ph.D. Web pages:

XML Technologies. Doc. RNDr. Irena Holubova, Ph.D. Web pages: XML Technologies Doc. RNDr. Irena Holubova, Ph.D. holubova@ksi.mff.cuni.cz Web pages: http://www.ksi.mff.cuni.cz/~holubova/nprg036/ Outline Introduction to XML format, overview of XML technologies DTD

More information

EMERGING TECHNOLOGIES

EMERGING TECHNOLOGIES EMERGING TECHNOLOGIES XML (Part 3): XQuery Outline 1. Introduction 2. Structure of XML data 3. XML Document Schema 3.1. Document Type Definition (DTD) 3.2. XMLSchema 4. Data Model for XML documents. 5.

More information

AquaLogic Data Services Platform Tutorial: Part II

AquaLogic Data Services Platform Tutorial: Part II AquaLogic Data Services Platform Tutorial: Part II A Guide to Developing BEA AquaLogic Data Services Platform (DSP) Projects Note: This tutorial is based in large part on a guide originally developed for

More information

Part X. XQuery Querying XML Documents

Part X. XQuery Querying XML Documents Part X XQuery Querying XML Documents Torsten Grust (WSI) Database-Supported XML Processors Winter 2012/13 238 Outline of this part 1 XQuery Declarative querying over XML documents Introduction Preliminaries

More information

XML and information exchange. XML extensible Markup Language XML

XML and information exchange. XML extensible Markup Language XML COS 425: Database and Information Management Systems XML and information exchange 1 XML extensible Markup Language History 1988 SGML: Standard Generalized Markup Language Annotate text with structure 1992

More information

A Modular modular XQuery implementation

A Modular modular XQuery implementation A Modular modular XQuery implementation Implementation Jan Vraný, Jan Jan Vraný, Jan Žák Žák Department of Computer Science and Engineering, FEE, Czech Technical University Department of Computer in Prague,

More information

Introduction to XQuery and XML Databases

Introduction to XQuery and XML Databases Introduction to XQuery and XML Databases TEI@Oxford July 2009 XQuery While XSLT is good for transforming XML to other formats (XML, HTML, PDF, Text, etc.) sometimes you may wish to query a large database

More information

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Part VII Querying XML The XQuery Data Model Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153 Outline of this part 1 Querying XML Documents Overview 2 The XQuery Data Model The XQuery

More information

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

Part X. XQuery Querying XML Documents. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 246

Part X. XQuery Querying XML Documents. Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 246 Part X XQuery Querying XML Documents Torsten Grust (WSI) Database-Supported XML Processors Winter 2008/09 246 Outline of this part 1 XQuery Declarative querying over XML documents Introduction Preliminaries

More information

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath

Querying XML. COSC 304 Introduction to Database Systems. XML Querying. Example DTD. Example XML Document. Path Descriptions in XPath COSC 304 Introduction to Database Systems XML Querying Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Querying XML We will look at two standard query languages: XPath

More information

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p:// TDDD43

TDDD43. Theme 1.2: XML query languages. Fang Wei- Kleiner h?p://  TDDD43 Theme 1.2: XML query languages Fang Wei- Kleiner h?p://www.ida.liu.se/~ Query languages for XML Xpath o Path expressions with conditions o Building block of other standards (XQuery, XSLT, XLink, XPointer,

More information

Big Data Fall Data Models

Big Data Fall Data Models Ghislain Fourny Big Data Fall 2018 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special Relativity"

More information

Course: The XPath Language

Course: The XPath Language 1 / 27 Course: The XPath Language Pierre Genevès CNRS University of Grenoble, 2012 2013 2 / 27 Why XPath? Search, selection and extraction of information from XML documents are essential for any kind of

More information

Module 4. Implementation of XQuery. Part 1: Overview of Compiler, Runtime System

Module 4. Implementation of XQuery. Part 1: Overview of Compiler, Runtime System Module 4 Implementation of XQuery Part 1: Overview of Compiler, Runtime System Now let us talk XQuery Compile Time + Optimizations Operator Models Query Rewrite Runtime + Query Execution XML Data Representation

More information

DBS2: Exkursus XQuery and XML-Databases. Jan Sievers Jens Hündling Lars Trieloff

DBS2: Exkursus XQuery and XML-Databases. Jan Sievers Jens Hündling Lars Trieloff DBS2: Exkursus XQuery and XML-Databases Jan Sievers Jens Hündling Lars Trieloff Motivation XML ubiquitous data exchange format Can be used to present Object data, relational data, semi-structured data

More information

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq

Language. f SQL. Larry Rockoff COURSE TECHNOLOGY. Kingdom United States. Course Technology PTR. A part ofcenqaqe Learninq Language f SQL Larry Rockoff Course Technology PTR A part ofcenqaqe Learninq *, COURSE TECHNOLOGY!» CENGAGE Learning- Australia Brazil Japan Korea Mexico Singapore Spain United Kingdom United States '

More information

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations Show Only certain columns and rows from the join of Table A with Table B The implementation of table operations

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Mapping SPARQL and SQL to XQuery

Mapping SPARQL and SQL to XQuery Mapping SPARQL and SQL to XQuery Martin Kaufmann Master s Thesis Systems Group Department of Computer Science ETH Zürich http://www.systems.ethz.ch 15th September 2009 15th March 2010 Supervised by: Prof.

More information

XQUERY: an XML Query Language

XQUERY: an XML Query Language SQL-99 XQUERY: an XML Query Language 5/3-2002 by Pål Halvorsen (edited by N. Akkøk spring semester 2003) Contains slides made by Arthur M. Keller, Vera Goebel SQL-99 user-defined types (UDTs) methods for

More information

DEMO A Language for Practice Implementation Comp 506, Spring 2018

DEMO A Language for Practice Implementation Comp 506, Spring 2018 DEMO A Language for Practice Implementation Comp 506, Spring 2018 1 Purpose This document describes the Demo programming language. Demo was invented for instructional purposes; it has no real use aside

More information

XML Path Language (XPath)

XML Path Language (XPath) 2.0 W3C Recommendation 23 January 2007 This version: Latest version: http://www.w3.org/tr/2007/rec-xpath20-20070123/ http://www.w3.org/tr/xpath20/ Previous version: http://www.w3.org/tr/2006/pr-xpath20-20061121/

More information

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database: SQL and PL/SQL Fundamentals NEW Oracle Database: SQL and PL/SQL Fundamentals NEW Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals training delivers the fundamentals of SQL and PL/SQL along with the

More information

Navigation. 3.1 Introduction. 3.2 Paths

Navigation. 3.1 Introduction. 3.2 Paths 03Brundage_ch03.qxd 1/8/04 1:09 PM Page 63 C H A P T E R 3 Navigation 3.1 Introduction Once you ve constructed or loaded XML in a query, you need a way to navigate over that hierarchical data. In many

More information

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9)

MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 6 Professional Program: Data Administration and Management MANAGING DATA(BASES) USING SQL (NON-PROCEDURAL SQL, X401.9) AGENDA

More information

Marker s feedback version

Marker s feedback version Two hours Special instructions: This paper will be taken on-line and this is the paper format which will be available as a back-up UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE Semi-structured Data

More information

8. Relational Calculus (Part II)

8. Relational Calculus (Part II) 8. Relational Calculus (Part II) Relational Calculus, as defined in the previous chapter, provides the theoretical foundations for the design of practical data sub-languages (DSL). In this chapter, we

More information

Working with XML and DB2

Working with XML and DB2 Working with XML and DB2 What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined.

More information

Oracle Database: SQL and PL/SQL Fundamentals Ed 2

Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Oracle Database: SQL and PL/SQL Fundamentals Ed 2 Duration: 5 Days What you will learn This Oracle Database: SQL and PL/SQL Fundamentals

More information

Table of Contents. Preface... xvii

Table of Contents. Preface... xvii Table of Contents Preface...................................................................... xvii 1. Introduction to XQuery....................................................... 1 What Is XQuery? 1

More information

CSE 444 Final Exam. August 21, Question 1 / 15. Question 2 / 25. Question 3 / 25. Question 4 / 15. Question 5 / 20.

CSE 444 Final Exam. August 21, Question 1 / 15. Question 2 / 25. Question 3 / 25. Question 4 / 15. Question 5 / 20. CSE 444 Final Exam August 21, 2009 Name Question 1 / 15 Question 2 / 25 Question 3 / 25 Question 4 / 15 Question 5 / 20 Total / 100 CSE 444 Final, August 21, 2009 Page 1 of 10 Question 1. B+ trees (15

More information

XQuery 1.0: An XML Query Language

XQuery 1.0: An XML Query Language XQuery 1.0: An XML Query Language W3C Recommendation 23 January 2007 This version: Latest version: http://www.w3.org/tr/2007/rec-xquery-20070123/ http://www.w3.org/tr/xquery/ Previous version: http://www.w3.org/tr/2006/pr-xquery-20061121/

More information

MySQL Workshop. Scott D. Anderson

MySQL Workshop. Scott D. Anderson MySQL Workshop Scott D. Anderson Workshop Plan Part 1: Simple Queries Part 2: Creating a database Part 3: Joining tables Part 4: complex queries: grouping aggregate functions subqueries sorting Reference:

More information

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects

Table of Contents Chapter 1 - Introduction Chapter 2 - Designing XML Data and Applications Chapter 3 - Designing and Managing XML Storage Objects Table of Contents Chapter 1 - Introduction 1.1 Anatomy of an XML Document 1.2 Differences Between XML and Relational Data 1.3 Overview of DB2 purexml 1.4 Benefits of DB2 purexml over Alternative Storage

More information

Flow Control. CSC215 Lecture

Flow Control. CSC215 Lecture Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE COMP 62421 Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE Querying Data on the Web Date: Wednesday 24th January 2018 Time: 14:00-16:00 Please answer all FIVE Questions provided. They amount

More information

Navigating an XML Document

Navigating an XML Document University of Dublin Trinity College Navigating an XML Document Owen.Conlan@scss.tcd.ie Athanasios.Staikopoulos@scss.tcd.ie What is XPath? Language for addressing parts of an XML document Used in XSLT,

More information

Functional programming with Common Lisp

Functional programming with Common Lisp Functional programming with Common Lisp Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 81 Expressions and functions

More information

Course: The XPath Language

Course: The XPath Language 1 / 30 Course: The XPath Language Pierre Genevès CNRS University of Grenoble Alpes, 2017 2018 2 / 30 Why XPath? Search, selection and extraction of information from XML documents are essential for any

More information

Unit Assessment Guide

Unit Assessment Guide Unit Assessment Guide Unit Details Unit code Unit name Unit purpose/application ICTWEB425 Apply structured query language to extract and manipulate data This unit describes the skills and knowledge required

More information

Semantic Web. Querying on the Web: XQuery, RDQL, SparQL. Morteza Amini. Sharif University of Technology Fall 94-95

Semantic Web. Querying on the Web: XQuery, RDQL, SparQL. Morteza Amini. Sharif University of Technology Fall 94-95 ه عا ی Semantic Web Querying on the Web: XQuery, RDQL, SparQL Morteza Amini Sharif University of Technology Fall 94-95 Outline XQuery Querying on XML Data RDQL Querying on RDF Data SparQL Another RDF query

More information

1) Introduction to SQL

1) Introduction to SQL 1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

XQ: An XML Query Language Language Reference Manual

XQ: An XML Query Language Language Reference Manual XQ: An XML Query Language Language Reference Manual Kin Ng kn2006@columbia.edu 1. Introduction XQ is a query language for XML documents. This language enables programmers to express queries in a few simple

More information

Updating XML with XQuery

Updating XML with XQuery Updating XML with XQuery Web Data Management and Distribution Serge Abiteboul Ioana Manolescu Philippe Rigaux Marie-Christine Rousset Pierre Senellart Web Data Management and Distribution http://webdam.inria.fr/textbook

More information

MarkLogic Server. XQuery and XSLT Reference Guide. MarkLogic 9 May, Copyright 2017 MarkLogic Corporation. All rights reserved.

MarkLogic Server. XQuery and XSLT Reference Guide. MarkLogic 9 May, Copyright 2017 MarkLogic Corporation. All rights reserved. XQuery and XSLT Reference Guide 1 MarkLogic 9 May, 2017 Last Revised: 9.0-2, July, 2017 Copyright 2017 MarkLogic Corporation. All rights reserved. Table of Contents Table of Contents XQuery and XSLT Reference

More information

STIDistrict Query (Basic)

STIDistrict Query (Basic) STIDistrict Query (Basic) Creating a Basic Query To create a basic query in the Query Builder, open the STIDistrict workstation and click on Utilities Query Builder. When the program opens, database objects

More information

XML: Extensible Markup Language

XML: Extensible Markup Language XML: Extensible Markup Language CSC 375, Fall 2015 XML is a classic political compromise: it balances the needs of man and machine by being equally unreadable to both. Matthew Might Slides slightly modified

More information

Outline of the Presentation. Querying XML. A little bit of history. What is XML? XML Data Example (2) XML Data Example (1)

Outline of the Presentation. Querying XML. A little bit of history. What is XML? XML Data Example (2) XML Data Example (1) T H E 8 T H A N N U A L B E A T E C H N O L O G Y C O N F E R E N C E Outline of the Presentation Querying XML Daniela Florescu BEA Systems danielaf@bea.com What is XML? XML query language : the big picture

More information

A control expression must evaluate to a value that can be interpreted as true or false.

A control expression must evaluate to a value that can be interpreted as true or false. Control Statements Control Expressions A control expression must evaluate to a value that can be interpreted as true or false. How a control statement behaves depends on the value of its control expression.

More information

Querying XML Documents. Organization of Presentation

Querying XML Documents. Organization of Presentation Querying XML Documents Paul Cotton, Microsoft Canada University of Waterloo Feb 1, 2002 1 Organization of Presentation XML query history XML Query WG history, goals and status XML Query working drafts

More information

Introduction to Semistructured Data and XML. Management of XML and Semistructured Data. Path Expressions

Introduction to Semistructured Data and XML. Management of XML and Semistructured Data. Path Expressions Introduction to Semistructured Data and XML Chapter 27, Part E Based on slides by Dan Suciu University of Washington Database Management Systems, R. Ramakrishnan 1 Management of XML and Semistructured

More information

Big Data 11. Data Models

Big Data 11. Data Models Ghislain Fourny Big Data 11. Data Models pinkyone / 123RF Stock Photo CSV (Comma separated values) This is syntax ID,Last name,first name,theory, 1,Einstein,Albert,"General, Special Relativity" 2,Gödel,Kurt,"""Incompleteness""

More information

Semi-structured Data. 8 - XPath

Semi-structured Data. 8 - XPath Semi-structured Data 8 - XPath Andreas Pieris and Wolfgang Fischl, Summer Term 2016 Outline XPath Terminology XPath at First Glance Location Paths (Axis, Node Test, Predicate) Abbreviated Syntax What is

More information

Decision Making in C

Decision Making in C Decision Making in C Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed

More information

The XQuery Data Model

The XQuery Data Model The XQuery Data Model 9. XQuery Data Model XQuery Type System Like for any other database query language, before we talk about the operators of the language, we have to specify exactly what it is that

More information

M359 Block5 - Lecture12 Eng/ Waleed Omar

M359 Block5 - Lecture12 Eng/ Waleed Omar Documents and markup languages The term XML stands for extensible Markup Language. Used to label the different parts of documents. Labeling helps in: Displaying the documents in a formatted way Querying

More information

Extending XQuery with Window Functions

Extending XQuery with Window Functions Extending XQuery with Window Functions Tim Kraska ETH Zurich September 25, 2007 Motivation XML is the data format for communication data (RSS, Atom, Web Services) meta data, logs (XMI, schemas, config

More information

Bash shell programming Part II Control statements

Bash shell programming Part II Control statements Bash shell programming Part II Control statements Deniz Savas and Michael Griffiths 2005-2011 Corporate Information and Computing Services The University of Sheffield Email M.Griffiths@sheffield.ac.uk

More information

Control Structures. CIS 118 Intro to LINUX

Control Structures. CIS 118 Intro to LINUX Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true

More information

XML and Semantic Web Technologies. II. XML / 6. XML Query Language (XQuery)

XML and Semantic Web Technologies. II. XML / 6. XML Query Language (XQuery) XML and Semantic Web Technologies XML and Semantic Web Technologies II. XML / 6. XML Query Language (XQuery) Prof. Dr. Dr. Lars Schmidt-Thieme Information Systems and Machine Learning Lab (ISMLL) Institute

More information

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University

XPath. Asst. Prof. Dr. Kanda Runapongsa Saikaew Dept. of Computer Engineering Khon Kaen University XPath Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept. of Computer Engineering Khon Kaen University 1 Overview What is XPath? Queries The XPath Data Model Location Paths Expressions

More information