XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.

Slides:



Advertisements
Similar presentations
XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
Advertisements

2/10/05Salman Azhar: Database Systems1 XML Query Languages Salman Azhar XPATH XQUERY These slides use some figures, definitions, and explanations from.
XML: Extensible Markup Language
XML DOCUMENTS AND DATABASES
XML: Extensible Markup Language. Slide Chapter Outline Introduction Structured, Semi structured, and Unstructured Data. XML Hierarchical (Tree)
Lecture 10. Back to the table example We can now return to considering in detail the first XSLT style-sheet we saw –The one which, when applied to the.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 COS 425: Database and Information Management Systems XML and information exchange.
4/17/2017.
Object Oriented Databases - Overview
Department of Computer Sciences Bahria University (Karachi Campus)
XML Technologies and Applications Rajshekhar Sunderraman Department of Computer Science Georgia State University Atlanta, GA 30302
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
Introduction to XPath Bun Yue Professor, CS/CIS UHCL.
SD2520 Databases using XML and JQuery
4/20/2017.
Aalborg University – Department of Production XML Extensible Markup Language Kaj A. Jørgensen Aalborg University, Department of Production XML – Extensible.
ECA 228 Internet/Intranet Design I Intro to XSL. ECA 228 Internet/Intranet Design I XSL basics W3C standards for stylesheets – CSS – XSL: Extensible Markup.
XML – Data Model, DTD and Schema
10/06/041 XSLT: crash course or Programming Language Design Principle XSLT-intro.ppt 10, Jun, 2004.
Computing & Information Sciences Kansas State University Monday. 20 Oct 2008CIS 560: Database System Concepts Lecture 21 of 42 Monday, 20 October 2008.
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.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
WORKING WITH XSLT AND XPATH
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
Chapter 26 XML and Internet Databases Copyright © 2004 Pearson Education, Inc.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 6 XSLT (Based on Møller and Schwartzbach,
XPath. Why XPath? Common syntax, semantics for [XSLT] [XPointer][XSLT] [XPointer] Used to address parts of an XML document Provides basic facilities for.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
Copyright © 2004 Pearson Education, Inc.. Chapter 26 XML and Internet Databases.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 27 XML: Extensible Markup Language.
August Chapter 6 - XPath & XPointer Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
Database Systems Part VII: XML Querying Software School of Hunan University
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 26-2 Introduction Although.
[ Part III of The XML seminar ] Presenter: Xiaogeng Zhao A Introduction of XQL.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
Data Structures TREES.
The Semistructured-Data Model Programming Languages for XML Spring 2011 Instructor: Hassan Khosravi.
XML, XSL, and SOAP Building Object Systems from Documents CSC/ECE 591o Summer 2000.
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Object Relational Features
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
University of Nottingham School of Computer Science & Information Technology Introduction to XML 2. XSLT Tim Brailsford.
Martin Kruliš by Martin Kruliš (v1.1)1.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
XPath --XML Path Language Motivation of XPath Data Model and Data Types Node Types Location Steps Functions XPath 2.0 Additional Functionality and its.
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
XML Extensible Markup Language
CITA 330 Section 5 XPath. XSL XSL (Extensible Stylesheet Language) is the standard language for writing stylesheets to transform XML documents among different.
5 Copyright © 2004, Oracle. All rights reserved. Navigating XML Documents by Using XPath.
XML Schema – XSLT Week 8 Web site:
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
XML 1. Chapter 8 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE XML SCHEMA (XSD) 2 Schema is a record definition, analogous to the.
XML: Extensible Markup Language Abeiku Duncan Leslie Salami Anthony Mensah-Kumah Michelle Amarteifio Joseph Owusu-Badu.
CSE202 Database Management Systems
XML: Extensible Markup Language
Querying and Transforming XML Data
XML: Extensible Markup Language
{ XML Technologies } BY: DR. M’HAMED MATAOUI
XML in Web Technologies
Database Processing with XML
2/18/2019.
Presentation transcript:

XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria University (Karachi Campus) Content for this lecture is taken from: Chapter 11 of “Database Systems: Models, Languages …”, 6th Ed.” by Elmasri and Navathe (Chapter 12 of “Fundamentals of Database Systems” 6th Ed. by Elmasri and Navathe) 1

Topics to Cover  XML Languages  Xpath  XQuery  Extracting XML Documents from Relational Databases 2

XML Languages  Two query language standards emerged  XPath Provides language construct to specify path expressions to identify certain nodes (elements) or attributes within an XML document that match specific patterns  XQuery Uses XPath expressions but has additional constructs 3

XPath: Specifying Path Expressions in XML  XPath expression  Returns a sequence of items that satisfy a certain pattern as specified by the expression  Returned items are either values (from leaf nodes) or elements or attributes  Qualifier conditions Further restrict nodes that satisfy pattern  Separators used when specifying a path:  Single slash (/) - specifies that the tag must appear as a direct child of the previous (parent) tag  Double slash (//) - specifies that the tag can appear as a descendant of the previous tag at any level 4

XPath: Specifying Path Expressions in XML (cont’d.) 1. Returns the company root node and all its descendant nodes, i.e. returns the whole XML document. 2. Returns all department nodes (elements) and their descendant subtrees. 3. // is convenient if we do not know the full path name we are searching for, but do know the name of some tags of interest within the XML document. Returns all employeeName nodes that are direct children of an employee node, such that the employee node has employeeSalary value greater than

XPath: Specifying Path Expressions in XML (cont’d.) XPath has a number of comparison operations for use in qualifier conditions, including standard arithmetic, string, and set comparison operations. 4. Returns the same result as the previous one, except that the full path name is specified in this example. 5. Returns all projectWorker nodes and their descendant nodes that are children under a path /company/project and have a child node hours with a value greater than or equal to 20.0 hours. Note: For COMPANY XML document, stored at the first XPath expression should be written as: doc( 6

XPath: Specifying Path Expressions in XML (cont’d.)  To include attributes in Xpath expression, attribute name is prefixed by symbol.  Wildcard symbol *  Stands for any element  Example: /company/*  the result can be a sequence of different types of items 7

XPath: Specifying Path Expressions in XML (cont’d.)  Axes  Our previous examples only included three: 1. Child of current node (/) 2. Descendent or self at any level of current not (//) 3. Attribute of the current node  A more general model for path expressions called Axes has been proposed.  In it, it is possible to move in multiple directions from current node in path expression  Includes self, child, descendent, attribute, parent, ancestor, previous sibling, and next sibling 8

XPath: Specifying Path Expressions in XML (cont’d.)  Main restriction of XPath path expressions  Path that specifies the pattern also specifies the items to be retrieved  Difficult to specify certain conditions on the pattern while separately specifying which result items should be retrieved.  The XQuery language separates these two concerns, and provides more powerful constructs for specifying queries 9

XQuery: Specifying Queries in XML  The typical form a query in XQuery is known as FLWR expression  FLWR stands for the four main clauses of XQuery 1. FOR 2. LET 3. WHERE 4. RETURN  Zero or more instances of FOR and LET clauses allowed  WHERE clause is optional, but can appear at most once  RETURN clause must appear exactly once 10

1. Variables are prefixed with the $ sign. 2. LET clause assigns a variable to a particular expression for the rest of the query. 3. FOR clause assigns a variable to range over each of the individual items in a sequence. 4. WHERE clause specifies additional conditions on the selection of items. 5. RETURN clause specifies which elements or attributes should be retrieved from the items that satisfy the query conditions. 11

Other Examples: XQuery: Specifying Queries in XML (cont’d.) 12

XQuery: Specifying Queries in XML (cont’d.)  XQuery contains powerful constructs to specify complex queries:  Conditional quantifiers, aggregate functions, ordering of query results, selection based on position in a sequence, and even conditional branching. Hence, in some ways, it qualifies as a full-fledged programming language   Contains documents describing the latest standards related to XML and XQuery 13

Other Languages and Protocols Related to XML  The goal is to provide the technology for realization of the Semantic Web, where all information in the Web can be intelligently located and processed.  Extensible Stylesheet Language (XSL)  Define how a document should be rendered for display by a Web browser  Extensible Stylesheet Language for Transformations (XSLT)  Transform one structure into different structure 14

Other Languages and Protocols Related to XML (cont’d.)  Web Services Description Language (WSDL)  Allows description of Web Services in XML making the Web Service available to users and programs over the Web.  Simple Object Access Protocol (SOAP)  Platform-independent and programming language- independent protocol for messaging and remote procedure calls  Resource Description Framework (RDF)  Provides languages and tools for exchanging and processing of meta-data (schema) descriptions and specifications over the Web 15

Extracting XML Documents from Relational Databases  Creating hierarchical XML views over flat or graph- based data  Representational issues arise when converting data from a relational database system into XML documents  UNIVERSITY database example 16

17

18

19

 In this hierarchy, the combined COURSE/SECTION information is replicated under each student who completed the section. 20

Breaking Cycles to Convert Graphs into Trees  Complex subset with one or more cycles  Indicate multiple relationships among the entities  Even more difficult to decide how to create the document hierarchies  Can replicate the entity types involved to break the cycles and convert into a hierarchy 21

Breaking Cycles to Convert Graphs into Trees (cont’d.) 22

Other Steps for Extracting XML Documents from Databases 1. Create correct query in SQL to extract desired information for XML document 2. Restructure query result from flat relational form to XML tree structure 3. Customize query to select either a single object or multiple objects into document. For example: In Figure 12.13, the query can select a single student entity and create a document corresponding to that single student, or it may select several, or even all of the students and create a document with multiple students. 23

Conclusion  XPath and XQuery languages  Query XML data  Extracting XML documents from relational databases involve converting from flat to hierarchical structure.  There could be cycles which need to be broken by replicating some entities.  Other than conversion some additional steps need to be taken 24