2

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?

dan1st
  • 12,568
  • 8
  • 34
  • 67
Madjokr
  • 147
  • 2
  • 16

1 Answers1

1

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

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335