tags:

views:

67

answers:

3

I am adding contact functionality to my program, and I want to save the contact list of each individual user, what is the best solution for this? I am new to XML and databases and I don't know which would be best or if there is a database solution that saves locally. Thanks for the help.

+5  A: 

It depends on what platform you are targeting and the size and complexity of the data structures you want to persist. Obviously an open and easily readable format like XML or JSON or something else is preferable but for larger applications things like a SQLite database or even a custom save format might be appropriate.

So, the biggest things to consider are:

  • Support for your platform/language of choice
  • Importance of human-readability/hackability (could be desirable or very undesriable, and note that this also impacts the ability of third party developers to build applications that consume your saved data)
  • Size
  • Speed of accessing data (with a potential tradeoff of how much memory it would take to load it all into memory at once)

For some combinations of those a plain text file works, that gives near-universal language and platform support, human readable and editable, but could tend to get large for a fair amount of data. For larger applications, a SQLite database is the right answer though you have to check and make sure your platform/language supports it (most do), it means it can't be edited in a text editor (though users can use it with sqlite itself to modify), and it will be fairly compact and quite fast.

Daniel DiPaolo
Thank you for your response Daniel. Do you know of any good SQLite references for using it with C#?
Joe Deak
+1  A: 

There are several options, with different trade-offs. One is SQLite, a public domain relational database that stores the database in a single file. It has bindings for most languages.

EDIT: A good binding I've used for C# is System.Data.SQLite.

Matthew Flaschen
Thank you for your response Matthew.
Joe Deak
Thanks Matthew, this looks like a good solution. Now just to figure out how to use it. ;)
Joe Deak
+1  A: 

Well, it's all about the nature of your data:

  • CSV, XML, JSON if it's a configuration file
  • SQLite if is database oriented data and you need to perform search

What language are you using ?

Cesar
He said in the OP it's contact data.
Matthew Flaschen
Thank you for your response Cesar.
Joe Deak