0

I am building a Winform application that need a database.

The database needs to save an array of items of a custom class:

Name
Date
Duration
Artist
Genre

If I should build the database using a file that every time, when I increase the array, I will save. Is there wait time to save an array of 300 or so items?

And the second database is to use SQL.

What is the difference between them? And what should I use?

6
  • I would recommend to use SQLite for that kind of things. It integrates quite well with visual studio, and also it is very lightweight. It is designed for that kind of application. But if you're not familiar with databases in general you can still start by saving to a file. The thing is, sooner or later I think you'll need a database if you plan on making your application evolve Commented Oct 9, 2013 at 10:22
  • You still need to consider on until when will your program be in use. But as my default answer, use SQL database. Commented Oct 9, 2013 at 10:48
  • @JackFrost What SQL would you suggest to use? Commented Oct 9, 2013 at 10:53
  • How will this application be distributed? Is it something that will only run on your LAN at work? Will users across the internet be able to download and install it? If so, should each user have their own private database, or are all instances of this application supposed to connect to 1 central database that you control? Commented Oct 9, 2013 at 17:54
  • @mbeckish This application will distribute with download and install. and every one need to have is own database. Commented Oct 9, 2013 at 20:53

3 Answers 3

2

As someone mentioned in a comment, SQLite should work very well for this type of scenario.

If you think your data set will remain fairly small, you might consider XML, or a file, or something else if you think that would be quicker/easier.

In any case, I would strongly recommend that you hide your storage-logic behind an interface, and call only that from the winforms part of your application. This way you will be able to replace your storage-solution later if you should need to.

Update in response to comment: The reason for using SQLite instead of another DB System is that SQLite can be integrated directly into your application. Other DBMS`s will typically be external systems, that you just connect to from within your app.

A quick google search will provide you lots of info, such as this short article about using SQLite within a C# application.

Sign up to request clarification or add additional context in comments.

2 Comments

From the start it could be an array of 300 items or bigger. it's save history for the user. Why i should use sqlite? and not another sql database?
@MTA I've updated my answer. Short answer: SQLite can be integrated.
0

I think you have to think about the futured size of your data.

If you know that i future the data will grow up exponentially, i think you have to use a database System like SQL.

Otherwise if it is only for a few records, you can use a XML File instead.

If you are using a MS SQL Database, you can open a Connection while saving your data, and write it with a sqladapter into the database.

If you are using a XML file instead, you can use the XMLSerializer class for serialization of your own Business object.

Comments

0

File vs database? - it is easy. What is database - it is a file. Only it has an engine that knows how to manipulate that file. If you use file, you suddenly need to think, "what if?". What if file gets corrupted during write. Or what if computer shuts down in the middle of write? DBMS takes care of this issues by issuing all sorts of mechanisms such as uncommitted data files, etc. Now you will need to provide this mechanism yourself.

This is why you should write to file only non-critical data. For example, some user settings. Because if you lost that file, user can re-size controls again but no data will be at loss. Or log file is another good use of file. Because if you lose a log, you can live without. But if you lose months of worth of data...

In your case, I don't know, how user history is important. 300 items is not a large array. You can use XML by creating an object (class) and mark its properties with XML attributes and then use XML serializer to serialize your history into XML http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

But if it is going to grow and you not planning to age some of it and delete, look into RDBMS.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.