Why should I use XmlType instead of a relational database?

I am doing a job where I have to consider two solutions for storing text used on a web page. Scenario: There is one web page for one lecture and several lectures for one subject.

The first option is a normal relational database, this is normal.

Another alternative is a table with two โ€œnormalโ€ attributes and one with Oracle XmlType. In this xml file all data for one object will be saved. Thus, the xml file will contain data for several lectures. I need the pros and cons for alternative number 2. And why should I use alternative # 2 instead of # 1 ??

+4
source share
3 answers

In your first alternative, you will need to use the LOB data type for the column that stores the web pages. If you use VARCHAR2 , you will lose formatting.

In the second alternative to the XMLTYPE column XMLTYPE you can select the LOB/CLOB repository or you can partition it into relational tables and object representations. XMLTYPE not saved in external files.

The second alternative will give you the opportunity to search for XML documents using XPath expressions and index XML tags. Thus, it is more powerful than the first alternative.

0
source

The only reason for storing data in XML is to get the data in XML and want to treat it as one continuous container of stuff. Attempting to request XML is a challenge sometimes, regardless of the ability to do this with all of Oracle's fantastic features. I did this, but the performance penalty points may be rude, or you need to jump through hoops to get the indexes correctly.

For a small perspective, I'm going to turn to Joel for this: Back to Basics - Joel on Software

0
source

A few reasons I can think of (from the head):

  • If the data is not relational in nature, but rather hierarchical and irregular, then XML may be a more suitable storage option than trying to force the data into table structures.

  • If you store data as XML, it may be easier to convert it to XHMTL for display.

  • If the data is taken and needs to be edited in an authoring system that uses the XML format, you will save yourself on a sufficient amount of data conversion, saving and consuming it as XML.

Given that each lecture is a separate โ€œpageโ€ in your application, it seems to me more reasonable to split each lecture into a separate XML โ€œbucketโ€ rather than storing them all in one XML fragment.

0
source

Source: https://habr.com/ru/post/1384762/


All Articles