Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 storing a lsit of checkbox

Author  Topic 

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2005-12-25 : 15:17:45
what is the most correct way to store a checkboxe's that were selected,and save them by there id value for example.
and if i want to make a search for example if a user have choosen : 1,5,9,32
and i want to search who has choosen 1 and 9 i will get the relevent user
thnaks in advance
peleg

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-12-25 : 23:12:25
Many to Many Relationship

Users
UserID
Name
...

Choices
ChoiceID
Other attributes about the choice

UserChoice
UserID
ChoiceID

UserID and ChoiceID combined would be the primary key for the UserChoice table. Since you want to do queries to see who made choice 1 and 9 you will need to put an index on choice id (assuming that UserID is the first column you selected in your primary key).

Go to Top of Page

pelegk2
Aged Yak Warrior

723 Posts

Posted - 2005-12-26 : 01:54:14
so you say i need to make a table that will contain in each row 1 of a users choice and in another row the second choice and so on?

Israel -the best place to live in aftr heaven 9but no one wan't to go there so fast -:)
Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-12-26 : 12:21:28
Yes. If your not exactly sure why this is a good idea you may want to review the different normal forms when it comes to database design.

Good Luck,

Dustin Michaels

Go to Top of Page
   

- Advertisement -