The collection should be within the parent object when that tree relationship makes sense – i.e., if a fruit is associated with exactly one person. For any individual item of fruit that may be the case, but for fruit types, it is not. So I would go for something like
class Person {
List<FruitItem> Fruits;
string Name, Address;
}
class FruitItem {
FruitType Type;
int Mass;
Location WhereBought;
}
class FruitType {
string Name;
string CountryOfOrigin;
}
class DataModel {
List<Person> People;
List<FruitType> FruitTypes;
}
Question 2 is then just comparing collections. Add equality functions to FruitType to test what you want as 'equal':
class FruitItem {
...
public override Equals(object other){
FruitItem otherFruit = other as FruitItem;
return otherFruit != null && otherFruit.FruitType == FruitType;
}
public override int GetHashCode() { return FruitType.GetHashCode(); }
}
... and then write some code to compare the lists in the two people you want to check. (Is there a clever way, or is this 'sort and then compare items'?) Or if you want to do a grouping, make sure that the hash codes for a collection are calculated based on only their contents, and then use Linq to group on Fruits.GetHashCode().