|
Posted by JDS on 10/16/49 11:25
On Wed, 31 Aug 2005 08:43:51 -0700, frizzle wrote:
> If i have a new match, and the score is 5-3 how should
> i add 5 player's ID of players who scored (in a yet to
> create DB-field), in that way that i can get the person
> that scored the most ... (topscorer)
> And 2nd, and 3rd etc.
Seems clear.
For future expandability and programmability, I suggest that you create
the following additional tables (and rework the two existing tables to
point to the data in these new tables):
create table teams(id, team_name, [...other data about the team...])
create table box_scores ( id, match_id, player_id, points [... additional
info...])
And you would change the match field "opponent" to "home_team_id" and
"visitor_team_id"
And you would link the tables with joins on all the different ids.
Then you could use the box_scores table to generate the total score of the
match, the goals for each player, and other stuff that you can't really do
with your simpler table set up.
Now, this is a lot to bite off at one sitting for a newish MySQL/PHP
programmer, so go over what I've suggested and then come back with more
specific questions. Adding all these tables is called "normaliazation" --
the process of breaking out non-unique data into separate tables so that
you are never actually repeating the same data within a table.
Also, realize that there is more than one way to skin a cat and other folk
may suggest variations or completely different techniques to what I've
suggested.
later...
--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
Navigation:
[Reply to this message]
|