Re: Help with database structure
Thanks a lot, I'll look it over. I promised a friend to do this for him so I kind of have to do it now :P I know it's a large project to start out with, but hopefully it will work out. Again, thank you :-) On 21 Nov., 23:45, Grant Cox [EMAIL PROTECTED] wrote: http://manual.cakephp.org/chapter/models Read up on associations, and how they are meant to work. And perhaps make something a bit smaller until you understand what the difference between associations are. Anyway, this is the kind of structure I would start with for what you outlined. I've used the tennis analogy of game, set, match. DB Structure -- User - id - team_id Team - id - team_leader_id Match - id - winning_team_id (set when a match is completed) Set - id - match_id - winning_team_id (set when a set is completed) Game - id - set_id - home_team_id - away_team_id - home_team_score - away_team_score Associations -- User belongsTo Team User hasOne LeadTeam (class = Team, foreignKey = team_leader_id) Team hasMany Member (class = User) Team belongsTo Leader (class = User, foreignKey = team_leader_id) Match hasMany Set Match belongsTo WinningTeam (class = Team, foreignKey = winning_team_id) Set hasMany Game Set belongsTo WinningTeam (class = Team, foreignKey = winning_team_id) Game belongsTo HomeTeam (class = Team, foreignKey = home_team_id) Game belongsTo AwayTeam (class = Team, foreignKey = away_team_id) Game belongsTo Set --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Help with database structure
Hi. I am trying to create an online matchsystem kind of like this one: http://www.ngl-one.com/en/match/629/ Now, I decided to try and do this project in CakePHP, but I can't figure out how my database should be set up. At the moment I've nearly given up because it seems so chaotic, so now I ask for help with the structure: What the site is supposed to do: You can sign up as a user, and you can be invited to join teams = users table with id, name, team_id and country You can create teams = teams table with id, teamleader and teamname. I'm not sure how to add the members of the team here. Perhaps just keep it in the users table and find all where team_id = x? Then there's the tricky part, the matches. The teamleader can report the lineup (attending players) out of the players from his team = The table must include the lineup as well as both team_ids. Normally I would just associate with team_id but when there's two different team_ids for the same match how can this be done? Even worse, the match is played by 5 rounds. And each round is best of 3. What I need help with is the matches table, I just don't know how to do it with both several team_ids and several rounds in the same table with the same match_id. I know this gets off very confusing. Sorry for that but I'm having a hard time explaining this, I'm not native English speaker. Hopefully my intentions will get through :-) Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Help with database structure
http://manual.cakephp.org/chapter/models Read up on associations, and how they are meant to work. And perhaps make something a bit smaller until you understand what the difference between associations are. Anyway, this is the kind of structure I would start with for what you outlined. I've used the tennis analogy of game, set, match. DB Structure -- User - id - team_id Team - id - team_leader_id Match - id - winning_team_id (set when a match is completed) Set - id - match_id - winning_team_id (set when a set is completed) Game - id - set_id - home_team_id - away_team_id - home_team_score - away_team_score Associations -- User belongsTo Team User hasOne LeadTeam (class = Team, foreignKey = team_leader_id) Team hasMany Member (class = User) Team belongsTo Leader (class = User, foreignKey = team_leader_id) Match hasMany Set Match belongsTo WinningTeam (class = Team, foreignKey = winning_team_id) Set hasMany Game Set belongsTo WinningTeam (class = Team, foreignKey = winning_team_id) Game belongsTo HomeTeam (class = Team, foreignKey = home_team_id) Game belongsTo AwayTeam (class = Team, foreignKey = away_team_id) Game belongsTo Set On Nov 22, 6:39 am, eid [EMAIL PROTECTED] wrote: Hi. I am trying to create an online matchsystem kind of like this one:http://www.ngl-one.com/en/match/629/ Now, I decided to try and do this project in CakePHP, but I can't figure out how my database should be set up. At the moment I've nearly given up because it seems so chaotic, so now I ask for help with the structure: What the site is supposed to do: You can sign up as a user, and you can be invited to join teams = users table with id, name, team_id and country You can create teams = teams table with id, teamleader and teamname. I'm not sure how to add the members of the team here. Perhaps just keep it in the users table and find all where team_id = x? Then there's the tricky part, the matches. The teamleader can report the lineup (attending players) out of the players from his team = The table must include the lineup as well as both team_ids. Normally I would just associate with team_id but when there's two different team_ids for the same match how can this be done? Even worse, the match is played by 5 rounds. And each round is best of 3. What I need help with is the matches table, I just don't know how to do it with both several team_ids and several rounds in the same table with the same match_id. I know this gets off very confusing. Sorry for that but I'm having a hard time explaining this, I'm not native English speaker. Hopefully my intentions will get through :-) Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---