I'm not sure I understand your requirements entirely, but there are order insensitive functions you can use to generate a key for any pair of elements. Any commutative operation on the two keys would work, but if you use a hash you need to worry about collisions. If you take your two (or more) keys, and sort them, then concatenate them, you will have a simple compound key that will always be the same regardless of the original order of your values. If that's all you need, then you only need one row per combination of keys, and you can look up or store quickly given a set combination.
>From your original note it sounded like you may need to be able to look up all the combinations that include a partial key. In that case, you will have to store duplicate information for quick lookups. Dave On Tue, Nov 24, 2009 at 5:32 PM, Lars Francke <[email protected]>wrote: > > If you need to be able to scan/lookup based on two different key/values, > > then you will most likely need duplicate tables or duplicate rows. > > > > This is common when you need to support two different lookup/read > patterns. > > Thanks for the answer. I had hoped there was some kind of (order > insensitive) hash function for multidimensional data that generates > the same hash regardless of the order of elements but I've worked my > way through a fair share of papers without finding something. I had > just hoped I was missing the obvious. > > Lars >
