How to use XML as a database in windows phone 7 application?
I am developing window phone 7 application. I am new to the window phone 7 application. I am using xml as a database for my current application. I am using the following link to use the XML as a database.
http://rongchaua.net/blog/windows-phone-7-simple-database-example/
I have six tables (for e.g. table_A, table_B, table_C, table_D, table_E, table_F) for my current application. So should I create the six classes (for e.g. class_A, class_B, class_C, class_D, class_E, class_F) for my current application ? & should I use six XML files to store the values from these six classes ? Or should I create a single XML file & store the values from all six classes to this single XML file ? Please开发者_如何学Python guide me for the above issue ? If I am doing anything wrong then please suggest me right solution. If anyone is having anything other ideas which can be useful then please share the ideas.
Yes, you'll probably want to create a class for each table, acting as your "model" effectively. Whether you should have a single file containing everything or one file per table - or something else entirely - will depend on what you're trying to do.
If you always need all the data, and you're only ever reading it, then putting it all in one file would make sense. If you're writing to some tables but not others, it may well make sense to keep the files separate so you've got less data to rewrite. (You're probably going to have to rewrite the whole file each time you modify a file, after all.)
You probably don't want to reload the file every time you access the data - loading it once and keeping it in memory may well be fine. Again, it depends on what your data actually looks like. If you can't keep it in memory but you're querying it regularly, you may want to reconsider using XML in the first place - it's convenient in various ways, but you can't treat it like a real database, with indexed queries etc. It would be hard to perform a search without effectively doing a table scan.
精彩评论