Docsity

XML Data Management in DB2: Querying and Indexing Techniques, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download XML Data Management in DB2: Querying and Indexing Techniques and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Native XML Support in

DB2 Universal Database

Agenda

  • What is DB2 9 (Viper)?
  • Native XML in the forthcoming version of DB

Native XML Storage

XML Schema Support

XML indexes

Querying XML data in DB

  • Summery
  • New query language support (for XQuery), a new graphical query builder (for XQuery), and new query optimization techniques
  • New support for validating XML data based on user-supplied schemas
  • New administrative capabilities, including extensions to key database utilities
  • Integration with popular application programming interfaces (APIs)

XML Databases

XML-enabled Databases

 The core data model is not XML (but e.g. relational)

 Mapping between XML data model and DB’s data  model is required, or XML is stored as text

 E.g.: DB2 XML Extender v

Native XML Databases

 Use the hierarchical XML data model to store and

process XML internally  No mapping, no storage as text

 Storage format = processing format

 E.g.: Forthcoming version of DB

DB2 Hybrid XML Engine - Overview

Integration of XML & Relational Capabilities in DB

  • Native XML data type

(not Varchar, not CLOB, not object- relational)

  • XML Capabilities in all DB2 components
  • Applications combine XML & relational data

DB2 Hybrid XML Engine - Interfaces

  • Data Definition create table dept(deptID int, deptdoc xml);
  • Insert insert into dept(deptID, deptdoc) values (?,?)
  • Index create index xmlindex1 on dept(deptdoc) generate key using xmlpattern ‘/dept/name’ as varchar(30);
  • Retrieve select deptdoc from dept where deptID =?
  • SQL based Query select deptID, xmlquery('$d/dept/name' passing deptdoc as “d") from dept where deptID <> “PR27”;
  • XQuery based Query for $book in db2-fn:xmlcolumn('BOOKS')/book for $entry in db2-fn:xmlcolumn('REVIEWS')/entry where $book/title = $entry/title return {$entry/review/text()} ;

Native XML Storage

Information for Every Node

  • Tag name, encoded as unique StringID
  • A nodeID
  • Node kind (e.g. element, attribute, etc.)
  • Namespace / Namespace prefix
  • Type annotation
  • Pointer to parent
  • Array of child pointers
  • Hints to the kind & name of child nodes
  • (for early-out navigation)
  • For text/attribute nodes: the data itself

XML Node Storage Layout

XML Indexes in DB

  • Need index support to manage millions of

XML documents

  • Path-specific value indexes on XML columns to

index frequently used elements and attributes

  • XML-aware full-text indexing

XML Value Indexes

  • Table DEPT has two fields: “id” and “dept_doc”
  • Field “dept_doc” is an XML document:

John Doe 408 555 1212 344

  • CREATE INDEX idx1 ON DEPT(deptdoc) GENERATE KEY USING XMLPATTERN ‘/dept/employee/name’ AS SQL VARCHAR(35)
  • Creates XML value index on employee name for all documents

XML Value Indexes: Data Types

  • Allowed data types for indexes:
    • VARCHAR(n)
    • VARCHAR HASHED,
    • DOUBLE
    • DATE
    • TIMESTAMP
  • DB2 index manager enhanced to handle special XML

types (e.g., +0, -0, +INF, -INF, NaN)

XML Value Indexes (continued)

  • Node does not cast to the index type
    • No error is raised
    • No index entry created for that node
  • Single document (e.g., XML field from single

record) may contain 0, 1, or multiple index

entries

  • Different than relational index