views:

235

answers:

1

Hi, I want to store multiple column values in table.Lets take a example .. What are your favourite colors? the choices can be red,blue,green, orange. So lets assume, the user selects atleast 2 values.

Is there any way to store the multiple values in table. I have implemented by concatinating choices of users in a column in the table. I later found that it is a bad practise.

Currently i can think of using Bitwise operator and habtm.

What are the different ways for storing multiple choices values in table? If I am implementing in rails, What is the best way to implement this with OOP concepts? Is there any builtin options in rails?

+1  A: 

The usual solution is to have a bridging table to create a many-to-many relationship.

David Dorward