Assume, we have classes A_1
to A_n
and classes B_1
to B_n
.
Each A_i
has relationships (abstract spoken; a relation could be 'A_4 likes B_2') to a set of B_j
's and the same the other way round.
Question: Where is a good place to store the relationship information ? Is there a good pattern for this kind of problem ?
Solution 1: Each A_i
has a list field store the B_j
's it has a relation with.
Solution 2: Each B_i
has a list field store the A_j
's it has a relation with.
Solution 1 and 2 are basically the same.
Solution 3: Store the information in a third 'information' class, e.g. as a matrix.