aspose file tools*
The moose likes General Computing and the fly likes XML or Database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "XML or Database?" Watch "XML or Database?" New topic
Author

XML or Database?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
What do you prefer? XML or Database? For storing things like configuration, which will not grow with time.

My personal choice is XML.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

One is a data format, the other is a storage mechanism. It is not either or. It is possible to store XML in a Database.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Henry Wong wrote:One is a data format, the other is a storage mechanism. It is not either or. It is possible to store XML in a Database.

Henry


Okay. Agreed.
But you do can store (keep) data in XML file.

Let me rephrase my question. What do you prefer? XML file or Database?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

ankur rathi wrote:
Let me rephrase my question. What do you prefer? XML file or Database?


Never really thought about it that much. I have done both.

Wrote lots of programs that read and save XML data as XML files.

Wrote some programs that parsed and save XML data in databases. Of course, you can argue that the data wasn't XML data anymore, as it has been parsed.


In a few cases, I did save raw XML data in a database. But in those cases, it was a corporate wide database. It was the best location to store something that was accessabile from everywhere in the company, was kept up at all times, was automatically backed up, and made highly available.

Henry
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5837
    
    7

I depends on the amount of data you will be storing. I have used XML files a few times when the amount of data was very small - the XML files never grew larger than 100KB. I usually read the file at startup and re-wrote the file any time any data changed. I expected at most 2 or 3 users, but I still synched the data changes.


JBoss In Action
Praveen Rajendran
Greenhorn

Joined: Dec 25, 2009
Posts: 21
I would like to comment on this way from an enterprise application standpoint...

XML files are good for storing configuration parameters which determine connectivity to external applications as you can carry those files always along with the application archive (deployable component)
Databases would be preferred for lookup data and storing those details which you do not wish to package along with the application.

In general databases are by default deemed for storing data while XMLs are more preferred to be used as means of propogating stored data rather than storing as static for frequent retrieval. If XMLs are used to store data then need to look for servers to store the XMLs itself.


Thanks & Regards,
Praveen
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Basically, like Praveen, I would store data in an XML document if I planned to update that document as a whole document, occasionally. So it would be useful for configuration files. If I planned to update small pieces of the data frequently, like keeping track of orders for a set of customers for example, I would store the data in a database.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
It depends on the type of data being stored. SGML-based or XML-based data files are the best practice for storing text-based content for technical manuals, books, CD-ROM, professional/legal information, etc. In many cases SGML/XML data files are in Giga/Terra byte range.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML or Database?