Context: SQL Server 2008, C#

I've a range of integers (-10 elements). Data does not change frequently, but is retrieved frequently.

I possibly could produce a separate table to keep the amounts, but for whatever reason it feels as though that would not be optimal.

Question #1: Must I store my array inside a separate table? Please give causes of one of the ways or another.

Question #2: (no matter exactly what the response to Q#1 is), what is the "best" method to store int[] in database area? XML? JSON? CSV?

EDIT: Some background: amounts being saved are simply some coefficients that do not take part in any relationship, and therefore are always used being an array (i.e. never something has been retrieved or utilized in isolation).

Separate table,stabilized

Less XML or json , but separate amounts in separate rows

Regardless of what you believe, it's the easiest way. You are able to thank me later

The "best" method to store data inside a database may be the way that's most favorable towards the procedures that'll be carried out onto it and one which makes maintenance simplest. It is primarily the later requirement that ought to make you a stabilized solution meaning storing the integers inside a table having a relationship. Beyond being simpler to update, it's simpler for the following developer which comes once you to know what and just how the details are saved.

Another table will be the most "stabilized" method of doing this. Which is better over time, most likely, because you will not need to parse the need for the column to extract each integer.

If you would like you could utilize an XML column to keep the information, too.

Sparse columns might be an alternative choice for you personally, too.

If you wish to ensure that it stays rather easy you can just delimit the values: 10;2;44;1

I believe as you are speaking about sql server that signifies that the application might be an information driven application. If that's the situation I'd keep certainly keep your array within the database like a seperate table having a record for every value. It will likely be stabilized and enhanced for retreival. Even when you simply possess a couple of values within the array you may want to mix that data along with other retreived data that might need to be "became a member of" together with your array values. By which situation sql is enhanced for by utilizing indexes, foreign secrets, etc. (stabilized).

That being stated, you could hard code the ten values inside your code and save the round visit to the DB if you don't have to alter the values. It is dependent how the application works and what this array will probably be employed for.

To be sure with the others concerning the best as being a separate stabilized table. But when you insist in getting everything within the same table don't put the array in a single only column. In rather produce the 10 posts and store each array value inside a different column. You will save the parsing increase problems.