Presentation is loading. Please wait.

Presentation is loading. Please wait.

8/17/20151 Querying XML Database Using Relational Database System Rucha Patel MS CS (Spring 2008) Advanced Database Systems CSc 8712 Instructor : Dr. Yingshu.

Similar presentations


Presentation on theme: "8/17/20151 Querying XML Database Using Relational Database System Rucha Patel MS CS (Spring 2008) Advanced Database Systems CSc 8712 Instructor : Dr. Yingshu."— Presentation transcript:

1 8/17/20151 Querying XML Database Using Relational Database System Rucha Patel MS CS (Spring 2008) Advanced Database Systems CSc 8712 Instructor : Dr. Yingshu Li

2 8/17/20152 Outline of Presentation 1. Background Information regarding XML 2. Storing XML documents in relational DB system 3. Querying & Manipulating XML data 1. XML Data Models for Query Processing 2. XML Labeling Schemes 3. Structural Joins 4. General Technique for Querying XML Documents using Relational DB System 5. XQL ( XML Query Language ) 6. Conclusion

3 8/17/20153 Background Information - XML  Evolved from a document markup language  For exchange of structured and semi-structured data  For self-describing data -> between heterogeneous data sources  XML Data Management Systems Specialized system – only for XML documents Specialized system – only for XML documents General System – manage XML along with other data formats. General System – manage XML along with other data formats.

4 8/17/20154 Background Information – XML ( Contd… )  XML is a recommendation of W3C  XML Schema – Type System for XML  XPath – A language for navigating within XML documents  XSLT – an XML transformation language  XQuery – a general purpose XML query language Based on XML Schema types Based on XML Schema types Includes XPath as a subset. Includes XPath as a subset.

5 8/17/20155 Storing XML Documents in RDB System 1 ) Simplest one is to use Long Character String data type like, CLOB in SQL  Will store entire document as a character string  Textual Fidelity  Fails to take advantage of structural information available in XML markup

6 8/17/20156 Storing XML Documents in RDB System ( Contd… ) 2 ) Shredding  Distributes XML information across one/more columns of tables preserving both data values & structural relationships.  For XML schema => tables levels of elements…. levels of elements…. at each level – different tables for elements in hierarchy Schema Based Shredding  Not efficient with sparse element - with varying contents sparse element - with varying contents Mixed contents – text + child elements Mixed contents – text + child elements  Fails to preserve Document ordering Document ordering Processing instructions of XML documents Processing instructions of XML documents

7 8/17/20157 Storing XML Documents in RDB System ( Contd… ) 3) XML Publishing  to reconstructs XML documents from relational tables, Systems usually provides inverse information called “XML Publishing”  Such Systems with shredding + XML publishing are said to provide Relational Fidelity  As authoritative form of data is relational, not XML. 4) Native XML with XML Fidelity.

8 8/17/20158 Querying & Manipulating XML Data  XML Storage facility -> interface to access and manipulate stored data.  XPath – better navigation within documents but, can not transform structures can not transform structures Can not construct new elements Can not construct new elements  XSLT – transformation + Construction But, Recursive template-driven nature – unsuitable for optimization Recursive template-driven nature – unsuitable for optimization  XQuery – complete set of query facilities.

9 8/17/20159 Querying & Manipulating XML Data ( Contd… )  XML Data Model XML documents as ordered, labeled, finite, unranked trees. XML documents as ordered, labeled, finite, unranked trees. Relative order of nodes – order of siblings Relative order of nodes – order of siblings Region encoding labeling scheme Region encoding labeling scheme Doc – to which document, node belongs toDoc – to which document, node belongs to Start & end – position of element in a documentStart & end – position of element in a document Level – level of a node in a treeLevel – level of a node in a tree X is an ancestor of y, if and only if X is an ancestor of y, if and only if x.start y.endx.start y.end

10 8/17/201510 Querying & Manipulating XML Data ( Contd… )  XML Labeling Schemes To evaluate queries in XPath, XSLT & XQuery, To evaluate queries in XPath, XSLT & XQuery, 1.Maintain results throughout the evaluation in document order Restricts choice of query plans Restricts choice of query plans Impossible if query requires data to be resorted along different axis at some point. Impossible if query requires data to be resorted along different axis at some point. 2.Sort Operator – handled at appropriate times Assign each node a label – denoting relative order Assign each node a label – denoting relative order Like, region encoding scheme Like, region encoding scheme Ancestor-descent problemAncestor-descent problem Variable size labeling scheme Variable size labeling scheme Do not need to relabel a node on update.Do not need to relabel a node on update. Difficult to allocate fixed portion of each record for label.Difficult to allocate fixed portion of each record for label.

11 8/17/201511 Querying & Manipulating XML Data ( Contd… )  Storing XML in RDBMS Labeling Scheme + edge shredding = form a single relation for storing XML Doc Labeling Scheme + edge shredding = form a single relation for storing XML Doc Edge relation Edge relation 1.Global Encoding Scheme Edge(id, parent-id, end, path-id, value) Edge(id, parent-id, end, path-id, value) 2.Local Encoding Scheme Edge(id, parent-id, sIndex, path-id, value) Edge(id, parent-id, sIndex, path-id, value) sIndex – position of a node among siblings sIndex – position of a node among siblings

12 8/17/201512 General Technique for Querying XML Doc in RDBMS  To store and query an XML Doc 1. Relational Schema Generation – table creation 2. Shredding – storing XML Doc 3. Converting queries over stored XML into SQL queries over created tables  Relational schema generation – requires its own query processor to convert the queries  But, the same query processor can be used..

13 8/17/201513 Contd...  To use the same query processor for relational schema generation and converting queries, Along with shredding, Reconstruction XML View is created over relational tables Along with shredding, Reconstruction XML View is created over relational tables Virtually reconstructs the Virtually reconstructs the Stored XML Doc <- shredded rows. Just like the normal view over the Stored XML Doc. Just like the normal view over the Stored XML Doc. Queries on Stored XML = Queries over Reconstruction XML View Queries on Stored XML = Queries over Reconstruction XML View

14 8/17/201514 Contd...

15 8/17/201515 Contd...  For Relational Schema Generation, a program that Generated desired relational schema Generated desired relational schema Produce XML Shredder object Produce XML Shredder object Create reconstruction XML view Create reconstruction XML view Either for,Either for, Shared relational schema Shared relational schema Edge relational schema Edge relational schema

16 8/17/201516 Contd...  Shared Relational Schema  Steps to generate relational schema Create a DTD Graph node ( XML Element, Attribute, Operator) Create a DTD Graph node ( XML Element, Attribute, Operator) Create a relation for root element in graph Create a relation for root element in graph All children of element are represented in same relation of element EXCEPT, All children of element are represented in same relation of element EXCEPT, *-node, - is a ‘set’ values + can’t captured by relational expressions*-node, - is a ‘set’ values + can’t captured by relational expressions So, create separate relation for these nodes.So, create separate relation for these nodes.

17 8/17/201517 Contd...

18 8/17/201518 Contd...

19 8/17/201519 Contd...

20 8/17/201520 XQL ( XML Query Language )  Structured Queries – relational / OO DB  Unstructured Queries – Documents  Semi-structured Queries – XML Documents  Features like, Allows, user to combine information from multiple sources Allows, user to combine information from multiple sources Uses links as a part of a query Uses links as a part of a query Search based on text containtment Search based on text containtment Eg ) Doc1 – recommended books Doc 2 – Books + Prices Doc 3 – Reviews of Books Then, a query -> list recommended books, prices and reviews.

21 8/17/201521 XQL ( XML Query Language ) Contd…  Difference between SQL & XQL Query SQLXQL The database is a set of tables.The database is a set of one or more XML documents. uses the structure of tables as a basic model. uses the structure of XML documents as a basic model. The FROM clause determines the tables which are examined by the query. A query is given a list of input nodes from one or more documents. The result of a query is a table containing a set of rows; this table may serve as the basis for further queries. The result of a query is a list of XML document nodes, which may serve as the basis for further queries.

22 8/17/201522 XQL ( XML Query Language ) Contd…  Basic Concepts of XQL Simple string – element name Simple string – element name Eg. tableEg. table ‘/’ – child operator – indicates hierarchy ‘/’ – child operator – indicates hierarchy Eg. Front/authorEg. Front/author ‘front/author='Theodore Seuss Geisel' ‘front/author='Theodore Seuss Geisel' front/author/address/@type='email' front//address //address front/author/address[@type='email'] front/author='Theodore Seuss Geisel'[@gender='male' and shoesize='9EEEE'] section[1,3 to 5, 8, -1] section[@level='3'][1 to 2]

23 8/17/201523 XQL ( XML Query Language ) Contd…  Example Queries

24 8/17/201524 XQL ( XML Query Language ) Contd…  Example Queries

25 8/17/201525 XQL ( XML Query Language ) Contd…  Grouping of results  Query –  lists the products on invoices might want to group products by invoice, placing each group of products within an invoice tag.

26 8/17/2015 26 XQL ( XML Query Language ) Contd…   Join   Combine information from multiple sources to create one unifies view.   Queries can be written like,

27 8/17/2015 27 Conclusion   XML Documents can be stored efficiently in a relational database system using number of approaches.   General Technique for storing and querying XML Document using RDBMS eliminated need of separate query processors for XML query translation.   Using General Technique Reconstruction XML View can be generated for both shared and edge based relational schema.   Stored XML Document can be queried effectively through the use of XQuery, XPath, XSLT or XQL.

28 8/17/2015 28 References   “XML and Relational Database Management Systems : the inside Story” by Michael Rys, Don Chamberlin, & Daniela Florescu.   “A General Technique for Querying XML Documents using a Relational Database System” by Jayavel Shanmugasundaram, Rajasekar Krishnamurthy, Igor Tatarinov.   “Querying and Maintaining Ordered XML Data Using Relational Databases” by Willium SHui, Franky Lam, Damien Fisher & Raymond Wong.   “Querying Structured Text in an XML Database” by Shurung Al-Khalifa, Cong Yu, H.V. Jagdish.   “Structured Materialized Views for XML Queries” by Andrei Arion, Veronique Benzaken & Ioana Manolescu.

29 8/17/2015 29 Thank You.   Any Questions ???


Download ppt "8/17/20151 Querying XML Database Using Relational Database System Rucha Patel MS CS (Spring 2008) Advanced Database Systems CSc 8712 Instructor : Dr. Yingshu."

Similar presentations


Ads by Google