473,415 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,415 software developers and data experts.

Store Multi-Select values in an image data type?

I was working on figuring out where a certain application was
storing the multiple selection choices I was doing through the app.
I finally figured out that they were being store in an IMAGE
data type colum with the variable length of 26 bytes.

This is the first time I ran into such way of storing multiple
selections in a single Image data type.

Is this a better alternative than to store into a One-to-Many
tables? If so then I'll have to consider using the Image data
type approach next time I have to do something like storing
1 to thousands of selections.

Thank you
Dec 20 '05 #1
4 2971
serge wrote:
I was working on figuring out where a certain application was
storing the multiple selection choices I was doing through the app.
I finally figured out that they were being store in an IMAGE
data type colum with the variable length of 26 bytes.

This is the first time I ran into such way of storing multiple
selections in a single Image data type.

Is this a better alternative than to store into a One-to-Many
tables? If so then I'll have to consider using the Image data
type approach next time I have to do something like storing
1 to thousands of selections.

Thank you


Define what you mean by "better alternative". This is a very poor
solution if you need to manipulate those values in the database. Much
easier to write TSQL against tables using a foreign key to implement
one-to-many relationships. It isn't likely to scale well either. How
are you going to search efficiently on an IMAGE type that contains
20,000 or 100,000 elements of data? How will you enforce referential
integrity with an IMAGE? It's for those kinds of reasons that
normalization is important.

Also, note that the IMAGE datatype is deprecated from SQL Server 2005
forwards and MS say it will be dropped in some future version.
VARBINARY(MAX) is the new type that provides more functionality,
although it won't answer the problems I mentioned before.

Just what advantage are you looking for that you cannot get from a more
conventionally designed data model?

--
David Portas
SQL Server MVP
--

Dec 20 '05 #2
serge (se****@nospam.ehmail.com) writes:
I was working on figuring out where a certain application was
storing the multiple selection choices I was doing through the app.
I finally figured out that they were being store in an IMAGE
data type colum with the variable length of 26 bytes.

This is the first time I ran into such way of storing multiple
selections in a single Image data type.

Is this a better alternative than to store into a One-to-Many
tables? If so then I'll have to consider using the Image data
type approach next time I have to do something like storing
1 to thousands of selections.


One wonders if the length is a mere 26 bytes, why they used image. A
varbinary or binary would do.

I can't say that I like this design. The only time I find it defendable,
is if the database don't have any information of the individual bits,
but they are handled exclusively by the application and the database is
just a place where the application saves its persistent data. I would
expect that to be a technical application for process monitoring or
some such. One real-world example is the system tables in SQL Server.
Several of these have status columns that are bit masks. (They are
integer though.)

For storing selection choices, I would much rather prefer to use a table
with a row for each choice. A bit mask certainly violates the principle
of no repeating groups.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 20 '05 #3
> One wonders if the length is a mere 26 bytes, why they used image. A
varbinary or binary would do.
Image doesn't accept a max column width; the max is always 2GB. I suspect
Serge was mislead by the 'text in row' table option since that is the value
SQL Server reports as the column width for text/ntext/image columns.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn**********************@127.0.0.1... serge (se****@nospam.ehmail.com) writes:
I was working on figuring out where a certain application was
storing the multiple selection choices I was doing through the app.
I finally figured out that they were being store in an IMAGE
data type colum with the variable length of 26 bytes.

This is the first time I ran into such way of storing multiple
selections in a single Image data type.

Is this a better alternative than to store into a One-to-Many
tables? If so then I'll have to consider using the Image data
type approach next time I have to do something like storing
1 to thousands of selections.


One wonders if the length is a mere 26 bytes, why they used image. A
varbinary or binary would do.

I can't say that I like this design. The only time I find it defendable,
is if the database don't have any information of the individual bits,
but they are handled exclusively by the application and the database is
just a place where the application saves its persistent data. I would
expect that to be a technical application for process monitoring or
some such. One real-world example is the system tables in SQL Server.
Several of these have status columns that are bit masks. (They are
integer though.)

For storing selection choices, I would much rather prefer to use a table
with a row for each choice. A bit mask certainly violates the principle
of no repeating groups.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Dec 20 '05 #4
Thank you both for your answers.

I am looking at an OLD SQL CRM application that
lets you create Views (application related Views and
not SQL Views) of your Companies list. You
select company names from all the Companies list
and then save the Views for later re-use.

For example the app displays me 50,000 companies
and I manually select 10 of them and save my
first view and give it a name "My Top 10 clients".

Another example I would select "My Top 100 clients"
and another "My Top 1000 clients".

If I do this right now in this app those 1000 ClientNos
will be stored in one IMAGE column on the same
record where my View information "My Top 1000 clients"
is being saved.

If I run the SQL Profiler every time I save my
View I see a lot of calls for "sp_cursorfetch" (I think)
or when I call my View to load I see a lot of cursor calls
(I am not sure if I remember if they were actually cursor
calls) but I saw a #Temptable being created and each
selected ClientNo's Name being inserted to this temp table.

Well it didn't look nice the SQL Profiler statements so
that's why I was just trying to see if the developer(s) of
this old CRM I was looking at had good reason(s)
to store the selections of a user into a single column.

Based on your answers if I need to implement such
a scenario I will stick to One-to-Many table relationship
for all the reasons you have explained.

Thanks again

Dec 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
0
by: Mark | last post by:
Hi all, I am just playing around with writing a simple space invaders game and was wondering what was the best way to store the layout of the "aliens". I am currently using a multi-dimensional...
2
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
2
by: Alan Silver | last post by:
Hello, I am designing a form that allows people to request the formation of a limited company. When they fill in the form, they have to supply a certain amount of information relevant to their...
33
by: Prasad | last post by:
Hi, Can anyone please tell me how to store a 13 digit number in C language ? Also what is the format specifier to be used to access this variable ? Thanks in advance, Prasad P
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.