I am working out a way to store the relationships between SQL tables for quick retrival. So if I have table A and table B, I'd like to know the relationship between the two. In a pseudo-xml (working towards evovling this to RDF) I'd represent relationships thusly:
<relationships>
<direct key1="csUsers.ID" key2="csUsers_lang.ID" />
<indirect key1="csUsers.ID" key2="csGroups.ID" >
<direct key1="csUsers.ID" key2="csUsers_Groups.ID" />
<direct key1="csGroups.ID" key2="csUsers_Groups.ID" />
</indirect>
</relationships>
I'd parse this in and cache it using Data::Dumper so I'd only have to re-parse when the data changes. The question here though is i'd want to be able to ask "how does csUsers relate to csGroups?" AND also be able to ask "how does csUsers relate to csGroups?"
So what comes to mind is a hash with two keys, which of course doesn't exist. I could nest hashes, but then that gives an order to the keys $hash{csUsers}{csGroups} is different than $hash{csGroups}{csUsers}. I can come up with arbitrary (read: alphabetic) ways to nest the hashes, but I'd rather not. Any suggestions on how to simulate a hash that takes a pair of keys in arbitraty order to return a value?