# Storing multiple choices in databases

**URL:** <https://discuss.rubyonrails.org/t/storing-multiple-choices-in-databases/2667>\
**Category:** rubyonrails-talk\
**Created:** [October 6, 2006, 12:13am UTC](https://discuss.rubyonrails.org/t/storing-multiple-choices-in-databases/2667 "2006-10-06T00:13:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dark\_Ambient](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Dark\_Ambient](https://discuss.rubyonrails.org/u/Dark_Ambient)\
**Post date:** [October 6, 2006, 12:13am UTC](https://discuss.rubyonrails.org/t/storing-multiple-choices-in-databases/2667/1 "2006-10-06T00:13:43Z")

</div>

As an example - you have a select list of all the U.S. states and the user can make multiple choices. How do you grab all those choices into the database and they would be used for queries. I was reading up on serialize() but the warning in AWDWR is that it doesn’t work well for queries. Also composites / aggragates seems a bit much, maybe not.

I know in the past I’ve used addtional tables as example.

Tavels\_table - id, user\_id States\_table - id, travel\_id, state id, travel\_id, state

```
                                                          id, travel_id, state

```

So if the user chose 3 states - each of the the 3 travel\_id’s above (in the States\_table) would be the same and correspond to the id in the Travels\_table. Almost makes you never want to offer multiple choice selects :).

TIA Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_Ambient](https://avatars.discourse-cdn.com/v4/letter/d/e9bcb4/32.png) [@Dark\_Ambient](https://discuss.rubyonrails.org/u/Dark_Ambient)\
**Post date:** [October 6, 2006, 9:41am UTC](https://discuss.rubyonrails.org/t/storing-multiple-choices-in-databases/2667/2 "2006-10-06T09:41:03Z")

</div>

Sorry, I know this might be off topic , more database design then Rails, but I’d like to know if there are ways in Rails to make this easier.
