S1r-Lanzelot
S1r-Lanzelot

Reputation: 2266

Using Settings.settings or a SQL database?

I am learning C# using Visual Studio and I am running into some issues.

I am developing a Windows form application. The application is meant to track user's running stats.

In settings: they select how many days they run and for each day they add their workout (ie: 1: 100m sprints 2: 50m sprints 3: Run a mile).

Then in the main windows form the user will be able to add their times and save it. Meanwhile a graph is projected of their times- this will allow the user to track their progress.

My question is where should I store their times? Right now I store all settings in the settings.settings doc. For the times should I use the settings file or a SQL database of some sort?

Upvotes: 1

Views: 152

Answers (2)

Dour High Arch
Dour High Arch

Reputation: 21712

It is not possible to answer you without a lot more information about what a "user's running stats" is and how it is used. I can give a few general guidelines, though.

System.Configuration.ApplicationSettings are designed for customizing an application for a specific user; for example, what language the user wants the application to use, where he wants windows to appear, or default values. Settings are part of the application; they are created when the application is installed and deleted when the application is uninstalled. If multiple users run the application, each typically gets their own settings. You typically define settings when you create the application and users never add or remove them.

Databases are used to persist user data. They are typically not tied to a specific user or application; users add the data, which is available to other users or applications. Applications typically aren't installed with all user data, nor is user data deleted when the application is uninstalled.

SQL databases are used for relational data; data that has internal structure, like "all users must have exactly one address", or "any user may have zero or more phone numbers". If your data is not relational you do not need a relational database.

These are general guidelines, specific applications may do things differently for specific purposes. If you tell us more about your application we will be able to provide more specific information.

Upvotes: 1

Anri
Anri

Reputation: 6265

SqlCE or SQLite or any other simple inproc database will be better than Settings file.

Settings are not meant to grow with every user input, this is a task for a database, also it will be much easier to query your data using SQL.

Answering your question in comments:

There is a difference between user data and user preferences. You have to decide which is what in your app.

I would go with Settings file with everything regarding user preferences. Like form layout, colors, sounds, window size and so on.

Since Settings managing framework is pretty sophisticated, you will save yourself some time designing tables for user preferences and developing access to that tables.

Another possibly bright side of Settings file - it can be edited manually with text editor.

Upvotes: 1

Related Questions