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