Message-ID: <[EMAIL PROTECTED]>
Date: Mon, 07 Mar 2005 13:01:45 -0600
From: Martin Norland <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Subject: Re: [PHP-DB] Re:data grabbing and mathematics!
1) use a single table, with 23 columns instead of 2. Then sum the columns in your query.
Actually I disagree strongly unless your intention is to be able to read the rows yourself !
As the stated intention is to add up scores (doing the maths) in fact much more efficiently you want to have just 3 columns in a single table, "tblBlah"
Using multiple tables, or even multiple columns is deeply inefficient for this.
Using multiple columns is the most space/time efficient - assuming players aren't only playing a few rounds.
Hi Martin - again I'd disagree with the space constraint : In the case of 3 columns I suggested, you keep *only* the data you require. If using 23 columns, you've now got to maintain 23 values (even if they have never been used). And worse, you have to make those values NULL by default - another 1 bit per item stored, and slightly slower query, which affects the time constraint if you grow to a very large system.
This is because as they're player scores - they have to be NULL initially to indicate the user never played the round. If you set them to zero by default, you have no idea if the user played the round, or just scored zero.
Using 3 columns as above, if you get a count(*) of zero for a query filtering by user and round, then your player has never played it. If you get a sum(score) of zero, he's played but scored zero.
It is, however, not the most *flexible*, as you're saying. You need to modify the number of columns if things ever change, though you aren't limited to the number of players.
I think both scenarios though, would require the number of columns to change if anything*significant* changed.
But with 3 column solution proposed, to add another round you just .... insert the data ;-)
With 23 columns you have to modify the database schema to add that extra column.
Both solutions probably require you to modify your php code a tiny bit for that 'future' mod.
Cheers - Neil
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php