Question

It's been a little while since I've done anything making a database so I was wondering if someone could help me out in organizing some data. This is what I have:

  • (X) TEAMS
    • (X) Players
      • (1) Name
      • (X) Playable Positions (positions can be played by any player on any team)
      • (X) Player Manager (can manager any player on any team)
      • (X) Player Trainer (can train any player on any team)
      • (X) Player Teacher (can teach any player on any team)
        • (1) Subject
        • (1) Years been teaching

Ideally I would put this into a simple MySQL DB but if there's another way/medium to organize this please let me know, I'm open to any and all suggestions.

Was it helpful?

Solution

Here is rough design: (you might have to modify db according to your requirements)

tblTeams
------------------------------
team_id    | int    | primary key
team_name  | varchar| not null

tblPositions
-----------------------------
position_id| int    | primary key
pos_name   | varchar|

tblPlayers
------------------------------
player_id  | int    | primary key
player_name| varchar
team_id    | int    | foreign key tblTeams(team_id)

tblManagers
-----------------------------
manager_id | int    | primary key
name       | varchar

tblManager_mapping
-----------------------------
id         | int    | primary key
manager_id | int    | foreign key tblManagers(manager_id)
player_id  | int    | foreign key tblPlayers(player_id)

tblSubjects 
----------------------------
sub_id     | int    | primary key
sub_name   | varchar

tblTeachers
-----------------------------
teacher_id | int    | primary key
name       | varchar

tblTeacher_player_mapping
-----------------------------
id         | int    | primary key
teacher_id | int    | foreign key tblTeachers(teacher_id)
player_id  | int    | foreign key tblPlayers(player_id)

tblTeacher_subject_mapping
-----------------------------
id         | int    | primary key
teacher_id | int    | foreign key tblTeachers(teacher_id)
sub_id     | int    | foreign key tblSubjects(sub_id)
teaching_since| date   

EDIT: Added new table as you clarified one player can have multiple positions. (also removed position_id from tblPlayers)

tblPlayers_position
-----------------------------
mapping_id | int    | primary key
player_id  | int    | foreign key tblPlayers(player_id)
position_id| int    | foreign key tblPositions(position_id)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top