Why should I use XmlType instead of a relational database?

1.2k views Asked by At

I'm doing an assignment where I am to consider two solutions for storing text used in a webpage. Scenario: there is one webpage for one lecture, and several lectures for one subject.

The first alternative is a normal relational database, this one is ok.

The other alternative is a table with two "normal" attributes, and one with Oracle's XmlType. In this xml-file all the data for one subject will be saved. So the xml-file will contain data for several lectures. I need some pros and cons for alternative #2. And why should I consider using alternative #2 in stead of #1??

3

There are 3 answers

0
Adam Hawkes On

The only reason to store data in XML is if you are receiving the data in XML and wish to treat it as one continuous container of "stuff". Trying to query XML is a challenge sometimes, regardless of the ability to do so with all the fancy Oracle functions. I've done it, but the performace penalties can be rough, or you have to jump through hoops to get the indexes right.

For a little perspective, I'm going to refer to Joel on this one: Back to Basics - Joel on Software

0
Larry Lustig On

A few reasons I can think of (off the top of my head):

  1. If the data is not relational in nature but rather hierarchical and irregular, XML might be a more appropriate storage option than trying to force the data into tabular structures.

  2. If you store the data as XML it may be easier to transform it to XHMTL for display.

  3. If the data originates in and needs to be edited in an authoring system that uses an XML format you will save yourself a fair amount of data transformation by storing and consuming it as XML.

Given that each lecture is a separate "page" in your application, however, it seems to make more sense to me to split each lecture into a separate XML "bucket" rather than storing them all in a single XML fragment.

1
Raihan On

In your first alternative you will have to use a LOB data type for the column storing the webpages. If you use VARCHAR2, you will loose the formatting.

In the second alternative for the XMLTYPE column you can choose LOB/CLOB storage or you can choose to break it up into object relational tables and views. XMLTYPE is not stored in external files.

The second alternative will give you the capability to search the XML documetns using XPath expressions and index the XML tags. So this is more powerful than the first alternative.