11

I'm working on a small project which will only have one user at a time since it's a local application (developed in WPF and C#). To store data I was thinking of using an XML file but I'm wondering if this would be the best approach.

What the data is for:

  • Shedules
  • Library of files in folders (with Artist name, Title, Location on HDD)
  • Possibly statistics based on the shedule data
  • ...

Information regarding the library would be fine in XML I imagine but about all the rest I'm not so sure. Also LINQ to SQL seems to be alot more profitable in terms of development speed than LINQ to XML. Is this correct or am I wrong? I was unsure if I should post this on SO or here but it seemed more appropriate here!

Thank you in advance

3
  • 3
    "One user at a time" is code speak for "in six months it will be our sole revenue stream and need to support 4,000 simultaneous users". Plan accordingly :) Aug 17, 2011 at 22:04
  • You don't even have to run a sql server service, you could just make it a file attached database if you're worried about migrating from machine to machine. Aug 17, 2011 at 22:25
  • 2
    no matter what you choose make an abstraction layer so you can easily swap out to another scheme when it becomes necessary Aug 17, 2011 at 22:27

3 Answers 3

13

If you will be doing lots of IO, SQL is your better choice. SQL is designed to work well to get/store data which is why we use it for storing data on something like a website as opposed to XML.

XML is good for human readable data that can be shared and interpreted between applications, as was its intention. XML parsing involves LOTS of string manipulation which can be come ever costly as the size of the data set increases.

1
  • 3
    Don't forget the Compact Edition.
    – JeffO
    Aug 18, 2011 at 1:08
1

It sounds as if your data could potentially grow infinitely (unless I misunderstood your application). In which case, I would say it's best to leave persistant storage up to a database engine for efficiency and performance.

0
0

Go with the database approach. It is the proven technology to handle data.

On the performance issue, you may be able to speed your access by having indexes, where in XML, no such means exist.

On a database, you can calculate statistical data using aggregate functions, in XML you got to code that.

Using a database, you can change the database structure with relative ease (add column, table, etc.) and there are tools to help you move the data between databases, where as in XML you got to do that yourself.

In a database, you can enforce integrity rules and you can let the users write their own selects if needed, not quite easy in XML.

In database, you can sort data very easily, also you can add security. Using a database, you can forget about size and concurrency, so in the future, your application can grow without code changes.

For the above, use a database! EK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.