1 / 39

XML Storage and Indexing Native XML

XML Storage and Indexing Native XML. Ervin Domazet Ahmed Cavit Zafar Hakan Demir. Outline. Two major classes of XML database Data versus Documents & their influence on storing XML data XML-enabled databases Storing and Retrieving Data in XML-enabled databases

Download Presentation

XML Storage and Indexing Native 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. XML Storage and Indexing Native XML Ervin Domazet Ahmed Cavit Zafar Hakan Demir

  2. Outline • Two major classes of XML database • Data versus Documents & their influence on storing XML data • XML-enabled databases • Storing and Retrieving Data in XML-enabled databases • Mapping Document Schemas to Database Schemas • XML Query Languages • Native XML databases • Storing Data in a Native XML Database

  3. Two major classes of XML database XML-enabled These map all XML to a traditional database (such as a relational database[1]), accepting XML as input and rendering XML as output. This term implies that the database does the conversion itself (as opposed to relying on middleware).

  4. Two major classes of XML database Native XML (NXD): The internal model of such databases depends on XML and uses XML documents as the fundamental unit of storage, which are, however, not necessarily stored in the form of text files.

  5. Data versus Documents & their influence on storing XML data • Characterizing documents as data-centric or document-centric will help to decide what kind of database to use. • As a general rule, data is stored in a traditional database, such as a relational, object-oriented, or hierarchical database. • This can be done by third-party middleware or by capabilities built in to the database itself.

  6. Data versus Documents & their influence on storing XML data • In the latter case(documents), documents are stored in a native XML database (a database designed especially for storing XML) or a content management system (an application designed to manage documents and built on top of a native XML database).

  7. A note on traditional databases and native XML databases • The boundaries between traditional(xml-enabled) databases and native XML databases are beginning to blur, as traditional databases add native XML capabilities and native XML databases support the storage of document fragments in external (usually relational) databases.

  8. Data-Centric Documents • A data-centric XML document contains regular repeating elements.  Child elements of a given element might all have the same tag name, or they might not.  Typically, child element order doesn’t matter.  There are lots of examples of this – many types of transforms of a relational database to XML results in data-centric XML. 

  9. Data-Centric Documents-Example • <Customers>  <Customer>    <Name>Bob</Name>    <Age>45</Age>  </Customer>  <Customer>    <Name>Jill</Name>    <Age>37</Age>  </Customer></Customers>

  10. Document-Centric Documents • Document-centric XML documents have the characteristic that the child elements of a given element are much less bounded – you might have many child elements of a given name, or you might have none.  • You might have ‘recursion’ in the hierarchy – element A is a child of element B, which is itself a child of a different element A.  A number of examples: Open XML word processing markup, XHTML, and XPS.

  11. Document-Centric Documents-Example • An Open XML paragraph that contains some bold text: <w:p><w:r><w:t>abc</w:t> </w:r><w:r><w:rPr><w:b/></w:rPr><w:t>def</w:t></w:r><w:r><w:t>ghi</w:t></w:r></w:p>

  12. XML-enabled Databases

  13. Storing & Retrieving DATA in XML-enabled databases • When transfering data between XML documents and a database, it is necessary to map the XML document schema (DTD, XML Schemas, RELAX NG, etc.) to the database schema. • The data transfer software is then built on top of this mapping. The software may use an XML query language (such as XPath, XQuery, or a proprietary language) or simply transfer data according to the mapping (the XML equivalent of SELECT * FROM Table).

  14. Storing & Retrieving DATA in XML-enabled databases • In the latter case, the structure of the document must exactly match the structure expected by the mapping. Since this is often not the case, products that use this strategy are often used with XSLT. That is, before transferring data to the database, the document is first transformed to the structure expected by the mapping; the data is then transferred. • Similarly, after transferring data from the database, the resulting document is transformed to the structure needed by the application.

  15. Mapping Document Schemas to Database Schemas • Mappings between document schemas and database schemas are performed on element types, attributes, and text. They almost always omit physical structure (entities, CDATA sections, and encoding info) and some logical structure (processing instructions, comments). • This is more reasonable than it may sound, as the database and application are concerned only with the data in the XML document.

  16. Mapping Document Schemas to Database Schemas • Two mappings are commonly used to map an XML document schema to the database schema: • Table-based mapping • Object-relational mapping

  17. Table-based mapping • The table-based mapping is used by many of the middleware products that transfer data between an XML document and a relational database. It models XML documents as a single table or set of tables. That is, the structure of an XML document must be as follows, where the <database> element and additional <table> elements do not exist in the single-table case:

  18. <database> <table> <row> <column1>...</column1> <column2>...</column2> ... </row> <row> ... </row> ... </table> <table> ... </table> ... </database>

  19. Example for table-based Mapping

  20. Object-relational mapping • The object-relational mapping is used by all XML-enabled relational databases and some middleware products. • It models the data in the XML document as a tree of objects that are specific to the data in the document. • In this model, element types with attributes, element content, or mixed content (complex element types) are generally modeled as classes. Element types with PCDATA-only content (simple element types), attributes, and PCDATA are modeled as scalar properties.

  21. Object-relational mapping • The model is then mapped to relational databases using traditional object-relational mapping techniques: • classes are mapped to tables, • scalar properties are mapped to columns, • object-valued properties are mapped to primary key / foreign key pairs.

  22. Possible mappings from an XML structure to an object-relational schema

  23. Object-relational mapping • It is important to understand that the object model used in this mapping is not the Document Object Model (DOM). • The DOM models the document itself and is the same for all XML documents, while the model described above models the data in the document and is different for each set of XML documents that conforms to a given XML schema.

  24. Query Languages • Template-Based Query Languages (*) • SQL-Based Query Languages (*) • XML Query Languages (**) • Xquery • XPath (*) - can only be used with relational databases (**)- can be used over any XML document

  25. XQuery • With XQuery, either a table-based mapping or an object-relational mapping can be used. • If a table-based mapping is used, each table is treated as a separate document and joins between tables (documents) are specified in the query itself, as in SQL. • If an object-relational mapping is used, hierarchies of tables are treated as a single document and joins are specified in the mapping.

  26. XPath • With XPath, an object-relational mapping must be used to do queries across more than one table. This is because XPath does not support joins across documents. Thus, if the table-based mapping was used, it would be possible to query only one table at a time.

  27. The overall picture of storage in XML-enabled databases

  28. Native XML Databases

  29. Storing Data in a Native XML Database • A Native XML database: • Defines a (logical) model for an XML document — as opposed to the data in that document — and stores and retrieves documents according to that model. At a minimum, the model must include elements, attributes, PCDATA, and document order. Examples of such models include the XPath data model, theXMLInfoset, and the models implied by the DOM and the events in SAX 1.0.

  30. Storing Data in a Native XML Database • A Native XML database: • Has an XML document as its fundamental unit of (logical) storage, just as a relational database has a row in a table as its fundamental unit of (logical) storage.

  31. Storing Data in a Native XML Database • A Native XML database: • Need not have any particular underlying physical storage model. For example, NXDs can use relational, hierarchical, or object-oriented database structures, or use a proprietary storage format (such as indexed, compressed files).

  32. Advantages of Native XML Databases • The first of these is when your data is semi-structured. That is, it has a regular structure, but that structure varies enough that mapping it to a relational database results in either a large number of columns with null values (which wastes space) or a large number of tables (which is inefficient).

  33. Advantages of Native XML Databases • A second reason to store data in a native XML database is retrieval speed. Depending on how the native XML database physically stores data, it might be able to retrieve data much faster than a relational database.

  34. Advantages of Native XML Database • A third reason to store data in a native XML database is that you want to exploit XML-specific capabilities, such as executing XML queries. Given that few data-centric applications need this today and that relational databases are implementing XML query languages, this reason is less compelling.

  35. Disadvantages of Native XML Databases • One problem with storing data in a native XML database is that most native XML databases can only return the data as XML. • If your application needs the data in another format (which is likely), it must parse the XML before it can use the data.

  36. Disadvatnages Native XML Databases • This is clearly a disadvantage for local applications that use a native XML database instead of a relational database. • It is not a problem with distributed applications that use XML as a data transport, since they must incur this overhead regardless of what type of database is used.

  37. The overall picture of storage in Native XML databases

  38. References • http://www.rpbourret.com/xml/XMLAndDatabases.htm, Ronald Bourret, XML and Databases • http://techessence.info/node/51Jenn Riley “Data-centric” vs. “Document-centric” XML • http://en.wikipedia.org/wiki/XML_database XML_Database

  39. Next • Data Types, Null Values, Character Sets, and All That Stuff

More Related