Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Extensible Storage Engine wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Functional Database Model wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Relational algebra wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Clusterpoint wikipedia , lookup
Versant Object Database wikipedia , lookup
Querying XML Database Using Relational Database System Rucha Patel MS CS (Spring 2008) Advanced Database Systems CSc 8712 Instructor : Dr. Yingshu Li 5/22/2017 1 Outline of Presentation Background Information regarding XML Storing XML documents in relational DB system Querying & Manipulating XML data 1. 2. 3. XML Data Models for Query Processing XML Labeling Schemes Structural Joins 1. 2. 3. 4. 5. 6. General Technique for Querying XML Documents using Relational DB System XQL ( XML Query Language ) Conclusion 5/22/2017 2 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 5/22/2017 Specialized system – only for XML documents General System – manage XML along with other data formats. 3 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 5/22/2017 Based on XML Schema types Includes XPath as a subset. 4 Storing XML Documents in RDB System 1 ) Simplest one is to use Long Character String data type like, CLOB in SQL 5/22/2017 Will store entire document as a character string Textual Fidelity Fails to take advantage of structural information available in XML markup 5 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…. at each level – different tables for elements in hierarchy Schema Based Shredding Not efficient with sparse element - with varying contents Mixed contents – text + child elements Fails to preserve 5/22/2017 Document ordering Processing instructions of XML documents 6 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. 5/22/2017 7 Querying & Manipulating XML Data XML Storage facility -> interface to access and manipulate stored data. XPath – better navigation within documents but, XSLT – transformation + Construction But, can not transform structures Can not construct new elements Recursive template-driven nature – unsuitable for optimization XQuery – complete set of query facilities. 5/22/2017 8 Querying & Manipulating XML Data ( Contd… ) XML Data Model XML documents as ordered, labeled, finite, unranked trees. Relative order of nodes – order of siblings Region encoding labeling scheme < doc, start, end, level > • Doc – to which document, node belongs to • Start & end – position of element in a document • Level – level of a node in a tree X is an ancestor of y, if and only if • x.start < y.start and x.end > y.end 5/22/2017 9 Querying & Manipulating XML Data ( Contd… ) XML Labeling Schemes To evaluate queries in XPath, XSLT & XQuery, 1. Maintain results throughout the evaluation in document order • • Restricts choice of query plans Impossible if query requires data to be resorted along different axis at some point. 2. Sort Operator – handled at appropriate times • • • 5/22/2017 Assign each node a label – denoting relative order Like, region encoding scheme • Ancestor-descent problem Variable size labeling scheme • Do not need to relabel a node on update. • Difficult to allocate fixed portion of each record for label. 10 Querying & Manipulating XML Data ( Contd… ) Storing XML in RDBMS Labeling Scheme + edge shredding = form a single relation for storing XML Doc Edge relation 1. Global Encoding Scheme • Edge(id, parent-id, end, path-id, value) 2. Local Encoding Scheme • • 5/22/2017 Edge(id, parent-id, sIndex, path-id, value) sIndex – position of a node among siblings 11 General Technique for Querying XML Doc in RDBMS To store and query an XML Doc 1. 2. 3. 5/22/2017 Relational Schema Generation – table creation Shredding – storing XML Doc 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.. 12 Contd... To use the same query processor for relational schema generation and converting queries, 5/22/2017 Along with shredding, Reconstruction XML View is created over relational tables Virtually reconstructs the Stored XML Doc <- shredded rows. Just like the normal view over the Stored XML Doc. Queries on Stored XML = Queries over Reconstruction XML View 13 Contd... 5/22/2017 14 Contd... For Relational Schema Generation, a program that Generated desired relational schema Produce XML Shredder object Create reconstruction XML view • Either for, 5/22/2017 Shared relational schema Edge relational schema 15 Contd... Shared Relational Schema Steps to generate relational schema Create a DTD Graph node ( XML Element, Attribute, Operator) Create a relation for root element in graph All children of element are represented in same relation of element EXCEPT, • • 5/22/2017 *-node, - is a ‘set’ values + can’t captured by relational expressions So, create separate relation for these nodes. 16 Contd... 5/22/2017 17 Contd... 5/22/2017 18 Contd... 5/22/2017 19 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 Uses links as a part of a query 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. 5/22/2017 20 XQL ( XML Query Language ) Contd… Difference between SQL & XQL Query SQL XQL 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. 5/22/2017 21 XQL ( XML Query Language ) Contd… Basic Concepts of XQL 5/22/2017 Simple string – element name • Eg. table ‘/’ – child operator – indicates hierarchy • Eg. Front/author ‘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] 22 XQL ( XML Query Language ) Contd… Example Queries 5/22/2017 23 XQL ( XML Query Language ) Contd… Example Queries 5/22/2017 24 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. 5/22/2017 25 XQL ( XML Query Language ) Contd… Join Combine information from multiple sources to create one unifies view. Queries can be written like, 5/22/2017 26 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. 5/22/2017 27 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. 5/22/2017 “Structured Materialized Views for XML Queries” by 28 Thank You. Any 5/22/2017 Questions ??? 29