none
When is it better to use XML files for stored data instead of an SQL database? RRS feed

  • Question

  • Hi,

    Having spent some time studying ADO.NET and LINQ it seems like there is a choice for storing data used by an application.

    Is there some 'rule of thumb' about always using SQL databases, or are there application characteristics that might make going with XML files a better choice?

    Roughly speaking, how might I go about making that decision?  When is it a better idea to use XML and when is it better to use SQL?

    Thanks!

    Best Regards,

    Alan

    Tuesday, May 27, 2014 9:51 PM

Answers

  • Hello,

    In my opinion, XML is viable depending on the context.

    If your data is pretty static, and not changing much (Sample data for example), the XML is a good use.

    Configuration settings, sample data (even if it's millions of rows, but rarely changing), are all good uses of XML.

    However, I would not store data to XML as to store it in database.

    XML is lousy for data storage. It is verbose. Data stored in an XML file will take much more disk space then the same data stored in any reasonable database system. In an XML record, the name of a particular field will be stored twice, along with the string representation of the data. For example, storing the value "1000000000" would still be 4 bytes in a real DB, while being 27 bytes in the XML.

    And XML is not a retrieval mechanism, so it cannot be a database. XML also happens to be a terrible storage format for more than maybe 1MB of data.

    If I misunderstand, please correct me.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Alan Wheeler Wednesday, May 28, 2014 2:57 AM
    Wednesday, May 28, 2014 1:37 AM
    Moderator

All replies

  • Hello,

    In my opinion, XML is viable depending on the context.

    If your data is pretty static, and not changing much (Sample data for example), the XML is a good use.

    Configuration settings, sample data (even if it's millions of rows, but rarely changing), are all good uses of XML.

    However, I would not store data to XML as to store it in database.

    XML is lousy for data storage. It is verbose. Data stored in an XML file will take much more disk space then the same data stored in any reasonable database system. In an XML record, the name of a particular field will be stored twice, along with the string representation of the data. For example, storing the value "1000000000" would still be 4 bytes in a real DB, while being 27 bytes in the XML.

    And XML is not a retrieval mechanism, so it cannot be a database. XML also happens to be a terrible storage format for more than maybe 1MB of data.

    If I misunderstand, please correct me.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Alan Wheeler Wednesday, May 28, 2014 2:57 AM
    Wednesday, May 28, 2014 1:37 AM
    Moderator
  • Hi Fred,

    That was great!  Your response addressed my question very clearly and I appreciate your time and insight.

    Thanks.

    Best Regards,

    Alan

    Wednesday, May 28, 2014 3:00 AM