Forum Moderators: open
Imagine there are 8 possible rock bands, represented as bits. Everyone has a eight bits representing which they like.
Jim likes 10010110
Jill likes 11010000
Bob likes 01000001
Ergo, Jim and Jill share bands one and four. Jim and Bob share no bands, and Bob and Jill share one.
My question is, how do I do the bitmath here, either in PHP or MySQL?
I have a much larger number of "bands" (eg., 800), which I plan to store as a binary field in MySQL. How do I get MySQL to return the 10 people who share the most band preferences with Jim? Alternately, if MySQL won't do it, how do I do the math in PHP?
My two cents:
IMO, it would be easier to set up a foreign key relationship between the two tables..
Fan
fankey, fanfirstName, fanlastName
Band
bandkey, bandGenre, bandName
BandsFans
bandsFansKey, bf_fanKey, bf_bandKey
so you have your bands, your fans, and your fans of bands, and you don't have to do any nasty binary math.
then you can do simple counts and group bys on the BandsFans table for your information.
Mark