In situations like this in the past I have created an integer column that bitwise operations can be performed against. Explanation below:
Begin by assigning a single binary digit to each value-
Cat Dog Firefly
--- --- ------
1 2 4
Next you will add an integer column to your main table, we will call it options. When the number is converted to binary each digit will represent weather cats, dogs or fireflys are allowed. Example:
5 = 101 in binary = Cats allowed, dogs not allowed, fireflys allowed.
id | locationName | options
---------------------------
1 | loc 1 | 5
2 | loc 2 | 2
3 | loc 3 | 7
4 | loc 4 | 6
We can now use bitwise operations against the options column to determine what options are allowed. Examples:
To get all records that allow dogs when we don t about cats or fireflys you would perform the following bitwise operation:
2 & options = 2
This would return records 2,3 and 4.
To get all records that allow dogs and fireflys we would perform he following bitwise operation:
6 & options = 6
This would return records 3 and 4
To get all records that allow cats and fireflys we would perform the following bitwise operation:
5 & options = 5
This would return records 1 and 3.
ONLY accepts fireflys:
4 | Options = 4
Doesn t accept fireflys:
4 & options = 0
This is probably a hard concept to grasp so please let me know if you have any questions. It seems to me that it might be the simplest way to accomplish what you are trying to do once you can grasp the concept.