开发者

Choosing the right relationship on Entity Framework and ASP.NET MVC

I'm new to ASP.NET MVC, so please pardon me if I mentioned wrong terminology on my question

I'm trying to create a soccer related application. Right now I'm trying to design the database / class structures for my application. However I run into a problem when I'm trying to define an appropriate class structure / business logic to represent a soccer match.

On every match 2 teams commonly play, and each team has different attributes (e.g. numbers of red cards, yellow cards and goals it receives), my question is how could you or woul开发者_开发知识库d you define that business rule in your entity framework structure?

Would it be appropriate for me to use inheritances relationship between those classes?

Here is what I've currently done:

Match Class with these attributes:

  • MatchID
  • Date
  • HomeTeam
  • AwayTeam

HomeGame

  • MatchID
  • TeamID
  • YellowCards
  • RedCards
  • Goals

AwayGame

  • MatchID
  • TeamID
  • YellowCards
  • RedCards
  • Goals

My question is what sort of relationship should I used to represent such business logic, perhaps inheritence, or would it be appropriate to use collection of class (Many to many relationship) instead?

I will gladly appreciate your input and/or suggestion

Thanks heaps!


HomeGame and AwayGame doesn't differ at all, so why to differ them on class/database structure level? I would use the same class here (let's call it GameAppearance for example) and just have two differently named properties of that type in Match class. No need to inherit anything here.

Match:

  • MatchID
  • Date
  • HomeTeam (of type GameAppearance)
  • AwayTeam (of type GameAppearance)

GameAppearance:

  • MatchID
  • TeamID
  • YellowCards
  • RedCards
  • Goals
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜