This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML as database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML as database" Watch "XML as database" New topic
Author

XML as database

Swathi Kota
Ranch Hand

Joined: Jun 04, 2008
Posts: 52
Hi all,
We are developing an application for which I am asked to use XML as database instead of the standard relational DBs like SQL.

Can anyone guide me as to where to start?how can i insert and update data into XML?Suggest me good books,links or anything useful.
Thanks in advance !


SCJP 6, SCWCD 5
Success is how high you bounce when you hit bottom
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Swathi,

If you have static XML document that is not going to change, its ok to use
that.Using XML as database is not a good/preferred option because of
following obvious reasons:

1- Inefficient for dynamic documents.
2- More disk space is required to store XML documents, because of
redundancy.
3- It is not practical for insert/update/delete operation as you need to
load entire XML document into memory (eg. using DOM) and modify its nodes as
required. After that you need marshal that document again into disk.
It is resource intensive and time consuming task.
4- You won't get benefits of relational database.

Generally XML is generated lookup into database or any data source
on the fly as per required depending upon user request for example.
[ November 05, 2008: Message edited by: Chandra Bhatt ]

cmbhatt
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Number 4 would be top of my list. Using an XML file(s) instead of a relational (or otherwise) database means your data store is:
  • non transactional
  • not available in distributed environments
  • will struggle to support concurrent access
  • does not guarentee ACID behaviour

  • etc.


    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18155
        
        8

    Here's a link to the Wikipedia article about XML databases. If you read it, you will see that the strategy of storing all your data in a single monster XML document isn't described there. I think that's because (as already mentioned by earlier posters) it really isn't a very good idea at all.

    But your task is just to "use XML as database". That doesn't necessarily mean one monster XML document anyway. It could mean something sensible. It could mean a lot of things. Perhaps you should clarify the requirements before you start designing (or buying).
    Jimmy Clark
    Ranch Hand

    Joined: Apr 16, 2008
    Posts: 2187
    An XML-based file format as a database can be an effective solution. It really depends upon the requirements and how the data will be processed, i.e. created, updated, edited, deleted.

    SGML-based databases have been around a very long time. Typically in the GB range. There are more efficient technoglogies than Java however. Do a search for OmniMark programming language.

    Check out the Apache Digester component

    http://commons.apache.org/digester/

    Checkout Apache XMLBeans

    http://xmlbeans.apache.org/

    Checkout the XML Cover Pages

    http://xml.coverpages.org/
    [ November 06, 2008: Message edited by: James Clark ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: XML as database
     
    Similar Threads
    Hibernate with RSS Feeds.
    can I use xml to develop a database for a JSP based web portal??
    DATABASE AND XML
    AutoSuggest drop down using Ajax
    XML and DB comp