Here is an example: Let's say I have a list of people, and for any pair of people I have some data - say the distance they live from each other.
Given a single person, I want to efficiently gather a list of all other people and their associated distances.
I could create a table like the following, but then I would have twice as many rows as I really need? E.g.
PersonA, PersonB, distance
PersonB, PersonA, distance
Are there better ways to do this? Also, aside from a database, are there data structures that solve this problem?