Hello guys, right now am trying to develope many php applications trying to learn php,
now am good enough to start my own project, and am thinking to develope a games staticstis site for PS3 players
I've done a leaderboard containe many players to get thier stats from Sony
here is an example : http://pic4u.netau.net/iqlb/indexv2.php
now am trying to add games sections which contain games that players have, so if someone clicked on player name it will shows his games,
now its come to my first question in project.
if I create a 'games' table in my DB how I linke those games to specific players ?

Recommended Answers

All 2 Replies

Disclaimer: I don't have a ton of experience designing DB schemas, and in fact my SQL is rusty, so I'm actually just putting this out there because I want to know others' thoughts.

I'd probably go about this having 3 tables:
players
* id
* name
* username
* etc.

games
* id
* name
* platform
* etc.

games_played
* player_id
* game_id
* hours_played
* etc.

This way you can run queries based on what you want. If you're on a player page, you could pull all records from games WHERE games.id = games_played.game_id AND games_played.player_id = [the player whose page you're on]. Alternatively, on a game page, you can list who's played the game by selecting from players WHERE players.id = games_played.game_id AND games_played.game_id = [the game whose page you're on].

Hope that makes sense.

commented: that fine idea +2

Ok thats a good idea but it will take many records in games_played table if I have 100 players and every player played 100 games that will be 10000 row, I can do this with one table.
I already have players table

players

*id
*username

games_table

*id
*player_id
*game_name
*last_played
*etc..

I want to reduce the amount of rows so I can update them easily.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.