views:

84

answers:

2

Hi I have a project where I need to store a large number of values. The data is a dataset holding 1024 2Byte Unsigned integer values. Now I store one value at one row together with a timestamp and a unik ID. This data is continously stored based on a time trigger.

What I would like to do, is store all 1024 values in one field. So would it be possible to do some routine that stores all the 1024 2byte integer values in one field as binary. Maybe a blobfield. Thanks.

Br. Enghoej

A: 

Yes. You can serialize your data into a byte array, and store it in a BLOB. 2048 bytes will be supported in a BLOB in most databases.

Reed Copsey
Thats sound great. Do I need some applet outside mysql to do this, or can it be done by an sql command? (Sorry my novice).Are you able to paste a code snippet or a link to some more detailed info how to do this.Thanks.
Here's some code showing how to do this with an image. The exact same code (C#) will work with any memory stream, which can be built off a byte[] array. If you give me your language of choice, I can probably find one in that language (although translating will be easy): http://forums.mysql.com/read.php?39,121077,122578
Reed Copsey
A: 

One big question to ask yourself is "how will I need to retrieve this data?" Any reports or queries such as "what IDs have value X set to Y" will have to load all rows from the table and parse the data AFAIK. For instance, if this were user configuration data, you might need to know which users had a particular setting set incorrectly.

In SQL Server, I'd suggest considering using an XML data type and storing a known schema, since this can be queried with XPath. MySQL did not support this as of 2007, so that may not be an option for you.

I would definitely consider breaking out any data that you might possibly need to query in such a manner into separate columns.

Note also that you will be unable to interpret BLOB data without a client application.

You always want to consider reporting. Databases often end up with multiple clients over the years.

TrueWill