Database Design for Sports Meeting (in MySQL)

I am trying to create a database for a sport meeting.

I think I have something good, but I'm not really sure.

The situation is as follows.

Meeting, several sports clubs will send several athletes: 1 or more. Athletes can participate in more than one event. There are several events: marathon, six, spear, ...

Each event has a first round, quarter-finals, semi-finals and finals. Each individual event has 1 employee who takes data, be it time, height or distance.

So basically, there is an N: M relationship here with athletes and events. 1 An athlete can enter many events, and there are many events that more than one athlete can enter.

I thought it would be the same with clubs and athletes, but I just put the "club_id" field in the athletes table to see which club came from.

What I have:

Table Clubs:
club_id int primary key auto_increment not null,
club_name varchar(50) not null

Table Athletes:
athlete_id int primary key auto_increment not null,
athlete_name varchar(40) not null,
athlete_club int not null,
index (athlete_club),
foreign key (athlete_club) references Clubs(club_id)

Table Events:
event_id int primary key auto_increment not null, (if there a new round, it a new event too)
event_name varchar(40) not null,
official_id int not null,
round enum('FIRST','QUARTER','HALF','FINAL')

Table Participations:
athlete_id int not null,
event_id int not null,
primary key (athlete_id,event_id),
index (athlete_id),
index (event_id),
foreign key (athlete_id) references Athletes(athlete_id),
foreign key (event_id) references Events(event_id)

      

And I think that's basically it. What's missing is a way to connect the series to the results. So I think there must be a different N: M ratio, since the athlete can go to the final or fall somewhere in the middle, but every round they did, their marks should be noted.

So, for example, I need to make a query that basically gives me "the names of all athletes whose times were faster than 5 minutes for a specific event in a specific round"

Or a list of rounds that one athlete did on one occasion, or a list of all athletes who got into a certain round ...

I'm not really sure how to add this.

0


source to share


2 answers


Add result field to participation table



+2


source


What is your question - an application question and then a DB question. Your DB design looks great for what you need. Now you need to write an application to query the database. Multiple SELECTS and JOINS and you shouldn't have a problem!



+1


source







All Articles