Oracle8i Application Developer's Guide - XML Release 3 (8.1.7) Part Number A86030-01 |
Library | Service | Contents | Index

Introduction to Oracle XML, 22 of 27

## Use a Hybrid Storage Approach for Better Mapping Granularity

In the previous section we discussed the following:

- How structured XML documents can be mapped to object-relational instances

- How unstructured XML documents can be stored in LOBs

However, in many cases, you need better control of the mapping granularity.

For instance, when mapping a text document, such as a book, in XML, you may not want every single element to be exploded and stored as object-relational. Storing the font information and paragraph information for such documents in an object-relational format, does not serve any useful purpose with respect to querying.

On the other hand, storing the whole text document in a CLOB reduces the effective SQL queriability on the entire document.

### A Hybrid Approach Allows for User-Defined Granularity for Storage

The alternative is to have user-defined granularity for such storage. In the book example, you may want the following:

- To query on top-level elements such as chapter, section, title, and so on, so these can be stored in object relational tables

- To query the book's contents in each section, and these can be stored in a CLOB.

You can specify the granularity of mapping at table definition time. The server can automatically construct the XML from the various sources and decompose queries appropriately.

Figure 1-3 illustrates the Hybrid approach to storage.

#### Figure 1-4 Hybrid Approach: Querying Top Level Elements in Tables While Contents are in a CLOB

### Hybrid Storage Advantages

The advantage of the hybrid storage approach for storing XML documents, is the following:

- It gives the flexibility of storing useful and queryable information in object-relational format while not decomposing the entire document.

- Saves time in reconstructing the document, since the entire document is not broken down.

- Enables text searching on those parts of the document stored in LOBs

| Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
Library | Service | Contents | Index