Let's say I have two tables - User and TrainingGroup. Relation between these two tables has to be like this:
- User can be in only one TrainingGroup
- One TrainingGroup can have multiple users
The problem happens because I need the following relationships as well:
- User can coach many TrainingGroups (group coach, eg. kids group, adults group etc.)
- Group can have only one user (coach)
Also, it is not possible for a user to be a coach and member of the group at the same time.
Is it possible to achieve that, and how? Any other design ideas?
Code block below roughly explains what I'm trying to achieve:
public class TrainingGroup
{
public User Coach { get; set; } // Coach of the group
public int CoachId { get; set; }
public List<User> Members { get; set; } //Members in the training group
}
public class User
{
public int TrainingGroupId { get; set; }
public TrainingGroup TrainingGroup { get; set; } // Group the user (Member) is training in
public List<TrainingGroup> CoachingGroups { get; set; } // Groups that the user is coaching
}