Suppose there are three tables (man, sport, number of goals scored) how to link them with foreign keys? if a person can participate in several sports, and in the table of goals scored, information is stored. for all goals of a person for each sport (i.e. the combination of sport / goals scored in this tabl. is not unique)

and how to calculate the average goals scored for each sport

  • Well, so you yourself wrote the structure of the database. in the third table id-records, id-man, id-kind-sports, goals. Although it is possible each goal is generally a separate line. Or make a unique bunch of id-man-id-kind-sport then store in it a single number the total number of the person’s goals - Mike
  • The problem is that I am not familiar with mysql much :) - mr.robot
  • And what is the average goals scored by sport. I understand by the sport "total goals", Maybe you mean the average number per person by sport? - Mike
  • rather, the average amount, i.e. divided by the amount - mr.robot
  • Divide the amount by the amount of what? In general, there is an avg () function for obtaining an average, the main thing in group by is to set the true extent to which extent we are grouping, and this just depends on what is “average by sport” and on what type of goals are stored in separate records for each goal or one line man-sport-number - Mike

0