0

first post coming from a beginner programmer so please be kind!

I am creating a very simple badminton session recording web app. It allows the organisor to create a badminton event and add users to it. The users are stored in a SQL table and ordered by a PlayerID PK. The (weekly) badminton events have their own table too.

What is the most 'learner programmer friendly' way to associate a group of 'attendees' (PlayerID), to the event?

My first thoughts are for each event to have another related table for 'attendees', but considering we have a weekly session that'd amount to a lot of tables.. (need to keep historical data/events)

thanks

MJay
  • 91
  • 9
  • It sounds like you have a many-to-many relationship. Take a look at: http://stackoverflow.com/questions/18603372/how-to-make-sql-many-to-many-same-type-relationship-table – Steve Jan 10 '14 at 09:22

1 Answers1

0

Thematically, it will be something like this:

Player

------------------------------
PlayerID | PlayerName | Gender | etc..
------------------------------
1        | PQR        | Male
2        | XYZ        | Male
3        | ABC        | Male

Event

-----------------------------
EventID | EventDate | etc..
-----------------------------
1       | 01-Jan-14 |
2       | 01-Jan-14 |
3       | 02-Jan-14 |

MatchDetails

----------------------------------
EventID | PlayerID | score etc...
----------------------------------
1       | 2        | 10
1       | 1        | 15
2       | 1        | 15
2       | 3        | 11
3       | 2        | 10
3       | 3        | 15

This way you can keep historical track of all the games as well as scores/outcome of the games as well.

hashbrown
  • 3,438
  • 1
  • 19
  • 37