views:

56

answers:

5

I am thinking of storing bunch of data in XML files. Each file will has information about a distinct element lets say contacts. Now I am trying to do retrieve a contact based on some information eg: Find all the contacts who live in CA. How do I search for this information? Can I use something like LINQ. I am seeing XElement but does it work for multiple XML files.

Does converting to datasets help? So I am thinking I should have a constructor for my application which loads all the xml files into a dataset and perform queries on the dataset. If this is a good approach can someone point me to examples/resources?

And most importantly is this a good solution or should I use databases? The reason I am using XML files is I need to extend this solution to use xquery in the backend tiers (business logic, database) in future and I thought having data in xml files would be helpful.

Update I already have the schema here - http://ideone.com/ZRPco

+3  A: 

If you put the data in a database then it's easy to output it as XML. Don't start off in XML just because you're going to need to end up there. If you're needing to do queries on the data then a database is almost certainly the best option.

Skilldrick
A: 

It definitely sounds like databases would be the correct solution. The two requirements I see here are you will need to run certain types of queries against the dataset and you need it to be in XML at a certain point. A SQL database will be able to handle complex queries a lot better than XML files while at the same time you can always convert the data to XML when you need it.

Justin Lucas
+1  A: 

Here are two reasons not to use XML ...

  1. if the dataset is large, i would not use xml. you either have a use a dom parser (slow on big data) or a sax parser (faster, but you lose validation ability until the whole file is read).

  2. if the data is going to change. You have to rewrite the whole xml file in order to change a portion of it.

Here is the reason I would use XML .. If the dataset is small, is naturally hierarchical, and needs to be viewable/editable in a text editor.

If you need to output as xml, it is not a problem to output xml from a database.

Don Dickinson
A: 

As per my experience, using XML as a master data source is not a good idea, it will be a pain at some point. Try SQLite instead, it is a powerful and portable relational database.

Jafet
+1  A: 

You can use XML in your cause. just to understand your example.

you may have 1000 Employees in your company. Each Employeer can have zero or more contacts( like primary, secondray, etc ). so every employeer can have a contacts.xml ( identified based on Xml Databases like eXist, MarkLogic, Berkely etc ).

e.g) -contacts.xml

Once the Data is inside an Xml Database. Then Database can fetch you all sort details based on what ever facet you want.

like fetch contacts by ZipCode, by City, by Name etc.

All you need to is write specific XQuery to mine the Data for your request. ( in case of MarkLogic Xml Database Server ). The Terminology used in this world is Faceted browsing.

Xml Databases are designed to handle such information. View Contacts as a Mass Data rather than Rows/Columns.

kadalamittai
Exactly the kind of solution I am looking for.. XML databases. So is there a way to this from C#/visual studio? But thanks for the pointers. One thing I was having trouble is how to structure my xml files.. should I create a seperate file for each tuple/entity or should I squash them into one gaint xml file?
satyajit
from my experiance content don't have to a single glob of data. Xml Databases are pretty sweeter in detailing multiple documents. Group them in a single logical entity to store it. But thats pretty much generic tought. in our cases we are having around 50 - thousand records as individual contents. nature of content being policy, permission, books, papers, standards and so on.
kadalamittai