SeanM Posted December 18, 2007 Share Posted December 18, 2007 Hello, I am an avid gamer, and I am part of a team as well. I am making a simple application online to help with the match organizations and such, but I have come across a problem. I have different teams in a table and I have different players in a seperate table like so - Table Structure for Players Table CREATE TABLE `players` ( `playersID` int(4) NOT NULL auto_increment, `country` char(2) NOT NULL, `bios` text NOT NULL, `specs` text NOT NULL, `email` varchar(255) NOT NULL default 'Enter E-Mail Here.', `xfire` varchar(255) NOT NULL default 'Enter Xfire Here.', `games` varchar(255) NOT NULL default 'Tell us what games you are currently playing.', `teamsID` int(3) NOT NULL, `name` varchar(255) default NULL, PRIMARY KEY (`playersID`) ) Table structure for teams table CREATE TABLE `teams` ( `teamsID` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `games_played` int(11) NOT NULL, `wins` int(11) NOT NULL, `losses` int(11) NOT NULL, `points` int(11) NOT NULL, `gamesID` int(11) NOT NULL, `tl_id` int(11) default NULL, PRIMARY KEY (`teamsID`) ) What I want to do, is each player has there own profile, and each player can be part of different teams (4v4 teams, 2v2 teams, etc...). The way I have it setup is that the teamsID corresponds to a teamsID in the players table. So when a player would join lets say teamID 2, then they would each get the same ID and then I can just draw the right players out for each team. But then, what if a player was part of 2 seperate teams? How would I go about setting that up? Thanks Sean Quote Link to comment Share on other sites More sharing options...
fenway Posted December 18, 2007 Share Posted December 18, 2007 Check out the sticky on db normalization... basically, rip out the teamID from the players table, and have a player_teams table that links the two. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.