1 / 100

All Your XML

All Your XML. Sandeepan Banerjee Oracle Corporation Sandeepan.Banerjee@Oracle.com. One Management System for All Your Data. Relational Characters, Numbers and Dates. Complete Integrated Robust Scalable Secure Available on all platforms. XML DB Integrated Native XML Database.

diella
Download Presentation

All Your XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. All Your XML Sandeepan Banerjee Oracle Corporation Sandeepan.Banerjee@Oracle.com

  2. One Management System for All Your Data RelationalCharacters, Numbers and Dates • Complete • Integrated • Robust • Scalable • Secure • Available on all platforms XML DBIntegrated Native XML Database Oracle Text & Ultra SearchText management and search Oracle Locator & SpatialLocation and Proximity Searching Oracle interMediaMultimedia management Oracle Collaboration SuiteUnified Messaging and Files Extensibility FrameworkChemical, Genetic, Engineering,…

  3. What is Oracle XML DB? • Database support for the XML data model • XMLType, XMLSchema, DOM Fidelity, Xpath, … • Hierarchical organization of the data • WebDAV compliant with indexing for fast access • Transparent storage optimizations • Query Language: SQL/XML (SQL2003) and XQuery

  4. Oracle XML DB Features • New XMLType • XMLSchema Support • Object-Relational Storage Maintaining DOM fidelity, CLOB storage with document fidelity • XML-specific memory mgmt for better scalability and performance • Lazily loaded virtual DOM, Schema caching • Built-in XML operators for SQL/XML interchangability • XPath Search in the server, and piecewise update of XML via XPath • XSL Transforms in the server • Enhanced XML Views for creating your own representations of XML • New XML Repository • FTP, WebDAV, HTTP protocol servers to move XML content in and out • ‘Foldering’ and Repository view over XML Content including access control • Hierarchical Index, SQL Versioning • SQL Repository Search

  5. Get better performance & scalability Enforce XML Schema Manage Content & Data Uniformly Eliminate extra moving parts Make DB applications Standards-based Common XML Architectures

  6. .NET Client JAVA Client OCI Client XML/DOM Parser XSL Transforms XML Schema Cache SQL XMLType Views/Tables Repository B-TreeBitmap Index Text Index Path Index Text Index XML DB Architecture Application Development JDBC/OCI/.NET Oracle*NET Oracle XML DB

  7. Protocol Handlers B-TreeBitmap Index Text Index XML DB Architecture Content Oriented Access HTTP Client FTP Client WebDAV Client HTTP WebDAV FTP XMLType Views/Tables Repository Oracle XML DB Text Index Path Index

  8. B-TreeBitmap Index Text Index XML DB Architecture Data & Content Integration Oracle XDS (JCA-based) Connectivity J2EE Query & Results Cache Web Services & Data Sources XML Query JVM SQL XML Query XMLType Views Repository Oracle XML DB Oracle HO Connectivity Relational DBs File Systems Web Sources

  9. XML DB Architecture Web Services Web ServicesDirectory UDDI WSDL Discover Publish SOAP 9iAS SOAP Server Web Service Client Application Invoke HTTP/Oracle*Net OracleXML DB

  10. XMLType Table XMLType Table XML DB Architecture XML Messaging Messaging Application IDAP/JMS/AQ Oracle*Net Transform Transform XML Document XML Document Oracle Streams Oracle XML DB Oracle XML DB EnQueue DeQueue

  11. Classes of XML Applications • Managing Structured Documents • Well-formed templated business-documents e.g. Purchase Orders, Phone Bills, … • Managing Unstructured Documents (“Content”) • Documents, Messages, Instructions • Life-cycle management of these assets under multiple channels • Querying over integrated, normalized data from diverse sources

  12. 1. Managing Structured Documents • Relational storage remains the “right” way to store highly structured data • “extended-relational” or “object-relational” mechanisms have been available for some time to deal with ordering, recursion, substitution etc. • As an XML programmer, you do not want to think about “tables” • A hierarchical data model is what you want to manipulate • XML DB’s XMLType is about preserving the XML paradigm while getting the benefits of relational performance and scalability

  13. D E M O N S T R A T I O N Structured XML

  14. Object Relational DB Basics • Object types • Collection types • Object References • LOBs

  15. XMLType • Native data type for XML • Used to define columns of tables and views, arguments to stored procedures, etc. • XML specific methods and operators for • Querying and extracting XML using XPath • Transforming XML using XSLT • Validating XML using XML Schema • Multiple Storage Options • Unstructured Storage in CLOB • Structured Storage into object-relational rows and columns • Hybrid Storage • Maintains application transparency to physical storage choice

  16. XML DB and XML Schema • XML Schema controls all aspects of processing • Storage mappings • In-memory representations • Language Bindings • XML Schema Registration Process • Associates XML Schema with URL • Generates Object types • Creates default tables • XMLType column can be constrained to a global element of registered schema

  17. XML Schema Example <schema targetNamespace=“http://www.oracle.com/PO.xsd” xmlns:po=“http://www.oracle.com/PO.xsd” elementFormDefault=”qualified” xmlns="http://www.w3.org/2001/XMLSchema"> <complexType name="PurchaseOrderType"> <sequence> <element name="PONum" type="decimal"/> <element name="Company"> <simpleType> <restriction base="string"> <maxLength value="100"/> </restriction> </simpleType> </element>

  18. XML Schema Example (contd) <element name="Item" maxOccurs="1000"> <complexType> <sequence> <element name="Part"> <simpleType> <restriction base="string"> <maxLength value="1000"/> </restriction> </simpleType> </element> <element name="Price" type="float"/> </sequence> </complexType> </element> </sequence> </complexType> <element name="PurchaseOrder" type="po:PurchaseOrderType"/> </schema>

  19. Generated Object Types TYPE "Item_T" (part varchar2(1000), price number); TYPE "Item_COLL" AS VARRAY(1000) OF "Item_T"; TYPE "PurchaseOrderType_T" (ponum number, company varchar2(100), item Item_COLL);

  20. Generated Tables TABLE po_tab OF XMLTYPE XMLSCHEMA “http://www.oracle.com/PO.xsd" ELEMENT "PurchaseOrder“ VARRAY(item) STORE AS item_tab;

  21. XML Document Example <PurchaseOrder xmlns="http://www.oracle.com/PO.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/PO.xsd http://www.oracle.com/PO.xsd"> <PONum>1001</PONum> <Company>Oracle Corp</Company> <Item> <Part>9i Doc Set</Part> <Price>2550</Price> </Item> <Item> <Part>8i Doc Set</Part> <Price>350</Price> </Item> </PurchaseOrder>

  22. XML Storage – PO_TAB and LINE_TAB

  23. Structured Storage • Attributes and single-valued elements • Stored as columns in single row • SQL data types correspond to XML Schema types • SQL constraints correspond to XML Schema constraints • Multi-valued elements (collections) stored in separate nested tables • One row per item in collection • Nested table row stores parent key • Array Index column stores the position information • Number column – uses full range of floating points • Elements inserted in the middle of the collection get (previous_array_index + next_array_index)/2 • Supports multiple levels of nesting • Embedded object types • Embedded collection types with multiple nested tables

  24. DOM Fidelity • Structured storage guarantees DOM fidelity • No whitespace fidelity • System binary attribute in object types • SYS_XDBPD$ • PD attribute stores non-relational information • Ordering of elements • Comments • Processing Instructions • Namespace declarations • Prefix information • Mixed content – text nodes that are intermixed with elements are stored in the system column

  25. Do you need it ? • Can disable on a Type by Type basis using annotation xdb:maintainDOM=“false” • Location of Namespace declarations • No Comments or Processing Instructions • Do not care about empty Vs missing elements • Elements in an All and Choice will be ordered as per the Schema, not the instance • Not worried about defaults • Type does not allow Mixed text

  26. Type defn with DOM Fidelity desc LINEITEMS_T LINEITEMS_T is NOT FINAL Name Null? Type ------------------------------- -------- ------------------ SYS_XDBPD$ XDB.XDB$RAW_LIST_T LINEITEM LINEITEM_V desc LINEITEM_V LINEITEM_V VARRAY(2147483647) OF LINEITEM_T LINEITEM_T is NOT FINAL Name Null? Type ------------------------------ -------- ------------------ SYS_XDBPD$ XDB.XDB$RAW_LIST_T ITEMNUMBER NUMBER(38) DESCRIPTION VARCHAR2(256 CHAR) PART PART_T

  27. Type defn without DOM Fidelity desc LINEITEMS_T LINEITEMS_T is NOT FINAL Name Null? Type ------------------------------- -------- ------------------ LINEITEM LINEITEM_V desc LINEITEM_V LINEITEM_V VARRAY(2147483647) OF LINEITEM_T LINEITEM_T is NOT FINAL Name Null? Type ------------------------------ -------- ------------------ ITEMNUMBER NUMBER(38) DESCRIPTION VARCHAR2(256 CHAR) PART PART_T

  28. xdb:maintainDOM <xs:complexType name="LineItemsType" xdb:SQLType="LINEITEMS_T" xdb:maintainDOM="false"> <xs:sequence> <xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded" xdb:SQLName="LINEITEM" xdb:SQLCollType="LINEITEM_V"/> </xs:sequence> </xs:complexType> <xs:complexType name="LineItemType" xdb:SQLType="LINEITEM_T" xdb:maintainDOM="false"> <xs:sequence> <xs:element name="Description" type="DescriptionType“ xdb:SQLName="DESCRIPTION"/> <xs:element name="Part" type="PartType" xdb:SQLName="PART"/> </xs:sequence> <xs:attribute name="ItemNumber" type="xs:integer" xdb:SQLName="ITEMNUMBER" xdb:SQLType="NUMBER"/> </xs:complexType>

  29. Dom Fidelity

  30. XDB Attributes in XML Schema • Mapping details captured as new attributes within the XML Schema • Oracle attributes use namespace : http://xmlns.oracle.com/xdb • Input XML Schema does not need to be annotated • Default assumptions for all XDB attributes • Input XML Schema can explicitly specify XDB attributes • SQLName : Name of column or type attribute • SQLType : Name of object type • SQLCollType : Name of collection type • MaintainOrder : Permits turning off order maintenance

  31. Hybrid Storage of XML • Two ends of storage spectrum • Store entire content in a single LOB • Full shredding of XML data • Hybrid Storage Options • Combination of shredding and LOB storage • xdb:SQLType=“CLOB” applied to <complexType> • CLOB storage ideal for fragments that are not intended for query or partial updates • Example : XHTML content embedded within resource descriptors (metadata)

  32. Querying XMLType • XPath based operators • existsNode • Boolean operator • Checks for existence of node identified by XPath • extract • Extracts a fragment identified by XPath • extractValue • Retrieves the raw value of leaf node identified by XPath • Namespace Aware • ANSI SQL/XML Standards effort

  33. Query Rewrite • Automatic rewrite of XPaths during query compilation • Rewritten query directly accesses underlying relational columns • Introduces joins with nested tables • Enables use of indexes

  34. Query Rewrite - Example • Original Query SELECT extractValue(value(p), '/PurchaseOrder/PONum') FROM po_tab p WHERE existsNode(value(p), '/PurchaseOrder[Company=Oracle]') = 1; • Rewritten Query SELECT p.ponum FROM po_tab p WHERE p.company = 'Oracle';

  35. Query Rewrite Examples

  36. Updating XMLType • Updating entire XML document • Partial Update • Uses UpdateXML() operator • XPath identifies element or attribute to be updated • New value for the updated node is specified • Rewritten to directly update underlying column(s) • Similar mechanisms for • Inserting new nodes • Deleting node(s)

  37. Update Rewrite - Example • Original Statement UPDATE po_tab p SET value(p) = updatexml(value(p), '/PurchaseOrder/PONum/text()', 9999) WHERE existsNode(value(p), ‘/PurchaseOrder[Company=Oracle]’) = 1; • Rewritten Statement UPDATE po_tab p SET p.ponum = 9999 WHERE p.Company = ‘Oracle’;

  38. XMLType Views • Provide an XML view of relational data • Good evolutionary strategy • New XML apps on XML abstraction of existing data • SQL/XML Standard operators used to generate XML • Views can generate schema based XML • Insert / Update / Delete operations via ‘Instead of’ Triggers • Queries over XML views are rewritten to directly access underlying relational columns

  39. XMLType View - Example CREATE VIEW po_view of XMLTYPE XMLSCHEMA "po.xsd" ELEMENT "PurchaseOrder" AS SELECT XMLElement("PurchaseOrder", XMLForest(p.ponum "PONum", p.company "Company"), (SELECT XMLAGG( XMLElement("Item", XMLForest(i.part "Part", i.price "Price")) FROM items_rel_tab i WHERE i.po_id = p.id)) FROM po_rel_tab p;

  40. Complex XML Schemas • Cyclic Definitions • Object types created with references • Table row contains reference to other rows stored in same or different table • Keys to document and parent rows stored in nested rows • Complex type derivation • Mapped to object type inheritance • Wildcards • Mapped to CLOB attributes

More Related