Jump to content

An array of tables?


rawb

Recommended Posts

I just wanted to get some advice from you experts before I embarked on a little project.. I'm trying to make an application that will manage a series of 1v1 tournaments for a video game (any of you ever played TFC?).

 

Anyways, the best way I could think of doing it was creating the following tables.. I'm a little new at this whole relational database thing so don't laugh if this is amateur..

 

users

id, name, etc.

 

tournies

id, date, etc.

 

teams[tourneyID]

userId, seed, etc.

 

matches[tourneyID]

id, winnerId, loserId, winnerScore, loserScore, etc.

 

As you can see, I would need two arrays of tables (one for teams and one for matches).. one table of each for each corresponding tourney.

 

I realize that I could just put another field in each of these tables to correspond to the tourneyID but that just doesn't seem like a great solution to me.  Also, I could just name the tables teams1, teams2, etc. and matches1, matches2, etc. and that would probably work just fine.. but I was wondering if there is a better/more accepted way to do this in mysql?  I hope I explained that so it makes sense.  Any advice before I begin?

Link to comment
Share on other sites

I think, I's the best solution to add another field (maybe a team_id/match_id), because many tables seem to decrease the speed of mysql.

Just create an index on the id. There you can select the different teams/matches.

Link to comment
Share on other sites

Since a single user references a single team the user table should hold the reference key, in this case a team_id

 

user.id

user.team_id

user.name

 

team.id

team.name

 

The following would then provide a list of all the users and their respective teams:

 

SELECT user.name, AS user_name, ifnull(team.name, 'No Team') AS team_name
FROM user
     LEFT JOIN team ON user.team_id = team.id
ORDER BY team.name, user.name

 

Use a single table for tournies and matches as well... search google for more information on relational database design.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.