Hi there,
I have this soccer site, and in 1 part one
can manage the played matches:
Score, location, players who scored etc.
Now the last part is what i have a question about.
The players are in a MYSQL db. Each has it's own
unique ID.
Fields:
- id
- firstname
- lastname
- position
Matches are also stored in the DB.
Fields:
- id
- opponent
- location
- date
- homepoints
- visitorspoints
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.
I hope it's clear.
Thanks in advance.
Greetings frizzle. 6 1197
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_i d"
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 | je*****@example .invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
On 31 Aug 2005 08:43:51 -0700, "frizzle" <ph********@gma il.com> wrote: Hi there,
I have this soccer site, and in 1 part one can manage the played matches: Score, location, players who scored etc.
Now the last part is what i have a question about. The players are in a MYSQL db. Each has it's own unique ID. Fields: - id - firstname - lastname - position
Matches are also stored in the DB. Fields: - id - opponent - location - date - homepoints - visitorspoints
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.
The players who scored in the match could be stored in a table like
this:
Name: matchscores
Fields:
match_id
player_id
totalscored
To get the scores list for a match, you could do a select like this:
SELECT * FROM matchscores WHERE match_id = ## ORDER BY totalscored
DESC
The end solution will really depend on what you've got at the moment
for storing the players who scored and how many changes you want to
make to the existing code.
Al
Wow, thank you both for the fast reply!
I haven't got anything yet, just building it in my head ;) .
JDS, thanks, what you describe is quite what i have in mind, which
would mean i am in the right direction, but doesn't really solve my
original problem if i understand it correctly.
Thanks for explaining so broadly!
What it comes to the home_team_id and visitor_team_id will
probably only be an INT wether the match is home(0), or out (1),
which tells me enough about who scored what.
AL also thanks a lot! I think this is quite what i want, but i'm
worried
that if this system is used for multiple years, the database will
become slow, since the system would create a new record for
each goal from our team ...
Or am i underestimating the power of PlaySt ..., erm, mySQL ?
Then another small problem i ran into: if players leave the team, and
are deleted from the list, what happens if he was the topscorer of a
certain year? That would return an empty record ...
is it a GOOD option not actually to delete them, but make them
'inactive'
(invisible for visitors (of the site, not a match ;) )
Thanks again and have a nice evening!
Greetings frizzle! ph********@gmai l.com says... Hi there,
I have this soccer site, and in 1 part one can manage the played matches: Score, location, players who scored etc.
Now the last part is what i have a question about. The players are in a MYSQL db. Each has it's own unique ID. Fields: - id - firstname - lastname - position
Matches are also stored in the DB. Fields: - id - opponent - location - date - homepoints - visitorspoints
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.
Suggestions if you really want to allow for increased data flexibility in
the future:
A player's position could change for match to match, so maybe it shouldn't
be a fixed attribute for the player, or maybe should be "usual_position ".
I'd use a third "player_mat ch" table,
Fields:
- match_id
- player_id
- played_position
- goals_scored
- .... other stuff you might want to record, field time (replacements
etc), cardings, a comments field ....
I'd probably look at recording all players not just goal scorers in this
table, more input time but more data to play with.
Assuming you are only going to record the details for you own club, not
the whole league, then alter your "matches" table and just have a column
for "opponent_goals ", then (presuming they refer to league table points)
homepoints and visitorspoints are just derived values.
Geoff M
frizzle wrote: I have this soccer site, and in 1 part one can manage the played matches: Score, location, players who scored etc.
Now the last part is what i have a question about. The players are in a MYSQL db. Each has it's own unique ID. Fields: - id - firstname - lastname - position
Bad idea. If a player changes a position, it will affect
your records of all previous matches in which that player
participated. Not to mention players changing teams...
Matches are also stored in the DB. Fields: - id - opponent - location - date - homepoints - visitorspoints
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.
Here's what I would do...
Table players:
id
firstname
lastname
Table teams:
id
name
Table matches:
id
hometeam (joins with teams.id)
visitor (joins with teams.id)
location
date
Table rosters:
id
match (joins with matches.id)
player (joins with players.id)
team (joins with teams.id)
position
Table goals:
id
match (joins with matches.id)
scored_by_team (joins with teams.id)
scored_by_playe r (joins with players.id)
Note that score is not recorded anywhere; it should be computed
by quering the `goals` table. Note also that this data design
allows you to record (and find) goals that players accidentally
scored against their own teams.
Now, figuring out top scorers becomes rather easy:
SELECT
players.firstna me AS first,
players.lastnam e AS last,
COUNT(goals.id) AS goals_scored
FROM goals LEFT JOIN players
ON goals.scored_by _player = players.id
GROUP BY players.id
ORDER BY goals_scored DESC;
Cheers,
NC
Wow, again, thanks for all this effort to help!!
'Position'-field is the position of players mostly, there will also be
e.g. haircolor, favorite music etc., so that won't be recorderd per
match.
Also own goals aren't going to be counted, but thanks for reminding me
of them! (Hope there won't be any ... :) )
I am going to record the score, because i want to leave a margin for
matches where people might forget who scored what goal, now they
can fill out 'unknown' to prevent the score from being incomplete ...
I think i'm going to use the following approach:
TABLE Players:
- id
- active
- firstname
- lastname
- position
- etc.
TABLE matches
- id
- opponent (id)
- location
- date
- home_goals
- visitor_goals
- etc.
TABLE goals
- id
- match_id
- player_id
players.active = 0 would mean a player isn't in the team anymore,
and is invisible in the team-list, but his score is counted, and his
name still appears in matches prior to his departure.
I believe this should work quite correctly, and be quite flexible.
Again, thanks a lot!
Still surprised time after time of the power of PHP/mySQL (either!)
Greetings Frizzle. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: obhayes |
last post by:
Hi,
I have two tables Table A and B, below with some dummy data...
Table A (contains specific unique settings that can be requested)
Id, SettingName
1, weight
2, length
Table B (contains the setting values, here 3 values relate to weight
|
by: Frank Lopez |
last post by:
In .NET and C#, is there anyway to create a hook for a specific
directory or file where my C# .NET software can monitor which static
web files are requested by the browser?
What I am doing is writing temporary files to a specific directory for
a specific user, and then when the user has requested each file in
that directory, I want to delete all of them.
It will also work if I can delete each temporary file after it is
requested. ...
|
by: Brian |
last post by:
NOTE ALSO POSTED IN
microsoft.public.dotnet.framework.aspnet.buildingcontrols
I have solved most of my Server Control Collection property issues.
I wrote an HTML page that describes all of the problems that I have
encountered to date and the solutions (if any) that I found.
http://users.adelphia.net/~brianpclab/ServerControlCollectionIssues.htm
This page also has all of the source code in a compressed file that you are
free to download...
|
by: SMG |
last post by:
Hi All,
My Send mail system was working very fine, today suddenly it started
giving me following error. Can any one suggest why this is happening so.
I am using system.Web.Mail
"The requested body part was not found in this message. "
Note : here XXXX and YYYYYYY are company specific info and nothing related
with code.
|
by: bfprog |
last post by:
Using IBM iSeries client access OLEDB provider to connect to DB2 on AS/400,
but cannot create connection using .NET web app. Using following code:
Dim cnTest As New OleDbConnection("Provider=IBMDA400; Data Source=S10324NM;
User ID=THEUSER; Password=THESECRET")
Works fine in console app, but fails in web app with:
System.Security.SecurityException: Requested registry access is not allowed.
| |
by: LP |
last post by:
Hi,
My webservice is currently deployed on WIndows 2000 server and runs pretty
fine. I am trying to run my webservice on a Windows 2003 server. My
webservice tries to write to a eventlog. The code is as follows:
System.Diagnostics.EventLog Log = new System.Diagnostics.EventLog(
EventLogName );
Log.Source = EventLogName;
Log.WriteEntry( "PCHistory Service Application started up successfully.",
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej and
I was wondering if anyone here would be able to give me some tips for
young players such as myself, for learning the language.
Is this the best Newsgroup for support with JAVA?
|
by: Shane |
last post by:
Does anyone have any advise on how I can fix the error message shown below?
Thanks in advance for any ideas,
Shane
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed
|
by: Hexman |
last post by:
Hello All,
I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm
using some VB6 code, .Net2003 code, and .Net2005 code. I'm developing in vb.net 2005.
This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to
a CSV file).
Some of my concerns are:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |