AR questions: bitmaps, parallel tables

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:

CREATE TABLE words (
id int,
length int, – word length
letters int, – bit map of letter use
lists int, – bit map of word lists
word char(50) – e.g., ‘polyglot’
);

SELECT letters, word
FROM words
WHERE length = 8
AND (letters & 0x123) = 0
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:

CREATE TABLE words_08 (
id int,
letters int, – bit map of letter use
lists int, – bit map of word lists
word char(8) – e.g., ‘polyglot’
);

SELECT letters, word
FROM words_08
WHERE (letters & 0x123) = 0
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

http://www.cfcl.com/rdm Rich M.
http://www.cfcl.com/rdm/resume [email protected]
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Technical editing and writing, programming, and web development