mobiledb icon indicating copy to clipboard operation
mobiledb copied to clipboard

Relationship Question

Open mxmissile opened this issue 11 years ago • 2 comments

Not really an "Issue" but more of a question.

Given Teams and Athletes, Athletes being members of Teams. How would you model this using mobiledb?

Say the Team entity has an Athletes property (Team.Athletes). And I wanted to see a list of all athletes regardless of the team. How would generate that query?

Same goes for reverse, say I have a list of Athletes, but needed to display the parent Team's name in the list. How do you query this without looping through all the athletes and querying the team for each athlete?

mxmissile avatar Nov 03 '14 22:11 mxmissile

mobiledb isnt able to detect this Kind of relationship at the Moment. but nevertheless you are able to model this relationship yourself.

Think about the following data Schema:

public class Team {
  [Identity]
  public Guid Id { get; set; }

  public string Name { get; set; }
}

public class Athlete {
  [Identity]
  public Guid Id { get; set; }

  public Guid TeamId { get; set; }

  public string GivenName { get; set; }

  public string SurName { get; set; }
}

With this model you're able to query all the examples above.

dbpprt avatar Nov 04 '14 08:11 dbpprt

And then use LINQ for joining. Total brain fart yesterday. Need to get out of the navigational properties mode that NHibernate gives you. Thanks @flumbee

mxmissile avatar Nov 04 '14 14:11 mxmissile