Docsity

Oracle XML DB and XQuery: Storage, Parsing, and Processing, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Oracle XML DB and XQuery: Storage, Parsing, and Processing and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Oracle XML DB and XQuery

Introduction

  • XML Type abstraction
  • Storage
    • Shredded or LOB
  • Publishing
    • XML Views of relational tables
  • SQL / XML functions and constructs
    • XMLQuery, XMLTable, and more...
    • XML Updates
  • XQuery evaluation and processing

XML View

  • Create virtual XML version of object-relational

data

  • Allows XQuery to access relational data
  • Uses XML Publishing
  • ora:view()

SQL/XML Functions

  • SQL/XML querying function and construct
    • XMLQuery, XMLTable
  • SQL/XML functions for creating XML from SQL
    • XMLElement(), XMLConcat(), XMLAttributes(), XMLForest()

XQuery Hybrid Evaluation

  • Transform XMLTable into XMLQuery
  • Static analysis and type checking
  • If possible, compiles into native SQL data

structures

  • If not possible, XMLQuery is left as is for

processing by XMLQuery processor

XQuery Hybrid Evaluation

SQL query containing XMLQuery/XMLTable

SQL query containing XMLQuery

SQL structures with XML operators

XQuery evaluated natively

SQL structures containing XMLQuery

Co-processor evaluates XMLQuery expressions

Transform XMLTable to XMLQuery

Native compilation of XMLQuery

Input & Data Representation

  • Each data row in separate DB row, column of XMLType

XMLType

XMLType

XMLType

Input & Data Representation

  • Each data row in separate DB row, contents in separate columns

VARCHAR

John Doe Adjuster Michael Smith Investigator Sam Adams Engineer

VARCHAR

VARCHAR VARCHAR

row

row

row

VARCHAR VARCHAR

Storage in Database

  • XMLType CLOB
    • File preserved as complete text (whitespace, comments, etc) [textual fidelity]
    • Can still be validated against a schema
    • Data internally is not “typed”
    • Slow querying
    • Fastest storage and retrieval

Storage in Database

  • XMLType View
    • Create a virtual XML document on top of relational tables
    • Fast querying, manipulation using pure SQL
    • Deeply nested views are slow
    • Updating/inserting requires triggers
    • Lose strict order guarantee, no textual fidelity
    • Supports multiple XML schemas on top of one relational schema

Structured Storage Detail

  • Annotate XML schema to control nested

collections storage, as:

– CLOB

  • Array of serialized SQL objects
  • Nested table of serialized SQL objects
  • Array of XMLType

Working with XML Schema

  • Registering schema

begin dbms_xmlschema. registerSchema ( ‘ http://namespace ', xdbURIType(' schema.xsd ').getClob(), TRUE,TRUE,FALSE,TRUE); end;

  • Creating table w/ schema

CREATE TABLE TableName of XMLType XMLSCHEMA "http://namespace"

XQuery database support

  • Production in Oracle Database 10gr
  • Supports XMLQuery and XMLTable construct
  • Native compilation into SQL /XML structures
  • Returns XMLType(Content)
  • Can query over relational, O-R, XMLType data
  • fn:doc - Maps to XDB Repository on server
  • SQLPlus provides xquery command to execute XQuery
  • XSL-T will also get compiled to XQuery

Architecture

XQuery XSL-T Parser

Compiler

XQuery Type check

XQ UE RY

SQL Metadata XMLSchema Repository

XML Indexes, Text Indexes

XQuery F&O

Rewrite to SQLX

SQLX rewrite

Relational Optimizer

Execution engine

Normalization XQueryX

Compiled XQuery Tree

Type checked^ Statically Tree Normalized Tree (casts, treat )

SQL/XML Operand Tree

SQL Operand Tree

Execution Structures

S Q L