sql - Correctly Modeling Sports Statistics in a Relational Database -


I am trying to model football figures in postgresql and do something like that, but it feels right does not do. Here's the problem:

I have team, sports and statistics. There are two teams for each game. There is an aggressive figure line in each team that can run, run, and so on. However, this aggressive situation is based on the defensive statistics of the other team, e.g. If the offensive team has a distance of 100 yards in the game against the defense team, then the rescue team has run away running 100 yards and it is important to track both these offensive and defensive statistics.

FootballTam, FootballGam, FootballStat and FootballTamstate, as a linking table between football and football, is a foreign key to footballgam in FootballStat. FootballTamstats have two foreign keys, one for FootballTam and one FootballStat. It also has a StatTypeId, which is a flag for any offensive or defensive. By doing so, I can avoid a lot of flaws in Footballstate, where I will have two rows for the same state, but an aggressive flag and a defensive flag.

It works very well in my current application, but it has never felt completely right. Is there a better way to do this? My database modeling experience is limited to projects in a great amount, which I have done after reading the database design for my deaths and when it adheres to my most experience, I'm not sure that this is the best way.

> Edit: Updated to make it normal rather than league specific.

You are on the right track, I only recommend giving tables a little better name: FootballSTAT and FootballTamst Read in the form of figures that were in existence with and without any team reference. ul:

IE: DEF: defensive, off: offensive


team-statistics-type-code

  • Description

IE: 1, for example, OFF, rushing

Team

  • Team-ID (PK)

Team-Statistics

  • Game-ID
  • Team-Statistics-Type-Code-ID (FK: Team-statistics-type
  • VALUE:
  • IE: 1, 1, 1, 100

    I know that offensive and defensive figures are important , But if any state will always remain aggressive and defensively - you can only get away with invasive data entering & amp; Using SQL to calculate defensive people IE: If dealing with 100 yards error is a defensive loss of 100 yards, do you benefit from the storage of protective information or should you make mapping in DB so that you can query Can I get SQL to reverse the values ​​through or see?

  • Game-ID
  • Home-Team-ID
  • Avi-Team-ID
  • Home-Scoring
  • Eyeworld

  • Comments

    Popular posts from this blog

    c# - ListView onScroll event -

    PHP - get image from byte array -

    Linux Terminal Problem with Non-Canonical Terminal I/O app -