Connecting Tech Pros Worldwide Forums | Help | Site Map

xml vs databases

Newbie
 
Join Date: Feb 2006
Posts: 2
#1: Feb 25 '06
I know that databases cannot be replaced by xml , and that they are complement to each other but I want to know if there are some cases or small applications where we need database but we can replace that by using xml only. If there is such cases please give me a small idea about that and what kind of applications can be done like that?

Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,183
#2: Feb 25 '06

re: xml vs databases


XML is/was designed as a way of exchanging data rather than storing it for which you would use a database.

However if the amount of data involved was small or did not need to be searched then you could use XML. For storing data XML has the following disadvantages:

1. It is not a very efficient way of storing data, there is a lot of wasted data(or meta data) to carry the actual actual data, for instance to carry somes name and age a database would need a record may be 20 bytes long but you would be hard pressed to fit that data into an xml file of the same size.

2. It is not easily searchable since every record would have to be in a separate file so search a set of records for a field with a given value you would have to open and parse every file.

Where I have seen it in (games) applications is to define the screen layouts (I'm thinking EverQuest), this is a sort of database (of all program screens) however the records do not need searching and they are limited so the data in-efficiency is not a problem and it has the advantage of allowing the user to customise their interface (if they know xml).

I also imagine it could be used to record games levels in the right sort of game.
Newbie
 
Join Date: Mar 2006
Posts: 10
#3: Mar 1 '06

re: xml vs databases


Quote:

Originally Posted by Banfa

XML is

2. It is not easily searchable since every record would have to be in a separate file so search a set of records for a field with a given value you would have to open and parse every file.

Sorry, I don't agree with you on this..
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,183
#4: Mar 1 '06

re: xml vs databases


Quote:

Originally Posted by Centaury

Sorry, I don't agree with you on this..

That's because you are correct a single xml file could contain a number of records my mistake :)

However a database is optimised for searching (normally) where as data stored in an XML file is stored as text and searching is going to require parsing at least one file and will not be as efficient. Obviously for a low number of small records this overhead may not be significant.
Reply