# AR questions: bitmaps, parallel tables

**URL:** <https://discuss.rubyonrails.org/t/ar-questions-bitmaps-parallel-tables/2970>\
**Category:** rubyonrails-talk\
**Created:** [October 12, 2006, 6:40am UTC](https://discuss.rubyonrails.org/t/ar-questions-bitmaps-parallel-tables/2970 "2006-10-12T06:40:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich\_Morin](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@Rich\_Morin](https://discuss.rubyonrails.org/u/Rich_Morin)\
**Post date:** [October 12, 2006, 6:40am UTC](https://discuss.rubyonrails.org/t/ar-questions-bitmaps-parallel-tables/2970/1 "2006-10-12T06:40:03Z")

</div>

I'm writing a "hangman" program that needs to look up sets of words by assorted characteristics (e.g., what letters does the word contain, which dictionaries is the word present in). The simple way to handle this is to create a single table, as:

&nbsp;&nbsp;CREATE TABLE words ( &nbsp;&nbsp;&nbsp;&nbsp;id int, &nbsp;&nbsp;&nbsp;&nbsp;length int, -- word length &nbsp;&nbsp;&nbsp;&nbsp;letters int, -- bit map of letter use &nbsp;&nbsp;&nbsp;&nbsp;lists int, -- bit map of word lists &nbsp;&nbsp;&nbsp;&nbsp;word char(50) -- e.g., 'polyglot' &nbsp;&nbsp;);

&nbsp;&nbsp;SELECT letters, word &nbsp;&nbsp;FROM words &nbsp;&nbsp;WHERE length = 8 &nbsp;&nbsp;AND (letters & 0x123) = 0 &nbsp;&nbsp;AND (lists & 0x12) != 0;

Unfortunately, I'm not sure how to use AR to select on a bit map. Is this supported?

Also, using a single table is inefficient, because I'll \_always\_ be selecting on word length. So, it would make more sense to do something like:

&nbsp;&nbsp;CREATE TABLE words\_08 ( &nbsp;&nbsp;&nbsp;&nbsp;id int, &nbsp;&nbsp;&nbsp;&nbsp;letters int, -- bit map of letter use &nbsp;&nbsp;&nbsp;&nbsp;lists int, -- bit map of word lists &nbsp;&nbsp;&nbsp;&nbsp;word char(8) -- e.g., 'polyglot' &nbsp;&nbsp;);

&nbsp;&nbsp;SELECT letters, word &nbsp;&nbsp;FROM words\_08 &nbsp;&nbsp;WHERE (letters & 0x123) = 0 &nbsp;&nbsp;AND (lists & 0x12) != 0;

However, I'm not at all sure how to do this using AR. I can imagine ways to create classes dynamically and store them in (say) an array, but this seems really baroque. Help?

-r
