Re: Best table structure
| From: | Miles Thompson | Date: | Wed, 30 Jun 2004 12:49:07 +0000 |
| Subject: | Re: Best table structure | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35051@lists.php.net to get a copy of this message | ||
Tom,
For a start, this is off-topic, and you also cross-posted - please don't do so.
Have a look at this article: http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
I prefer simpler tables, so I would use the structure you have suggested, with the possible addition of a date field and a field to indicate the source of the ranking.
With the proper use of indexes, the fetching of results is extremely fast; you don't have to worry about table size. Figure out the questions you have to ask of the information, and then decide what inputs you need to answer them.
Regards - Miles Thompson
At 07:53 AM 6/30/2004, Tom Chubb wrote:
Please can someone let me know their opinion on the following: I have written some code for submitting a top 20 music chart online. I use the following to insert into mysql: INSERT INTO chart (name, chartpos, artist, title, label) VALUES ('$name', '1', '$artist', '$title', '$label'), ('$name', '2', '$artist2', '$title2', '$label2'), ('$name', '3', '$artist3', '$title3', '$label3'), -------------- repeat til ----------------- ('$name', '20', '$artist20', '$title20', '$label20'), Another page queries the table and sorts by name (multiple people submit charts) and latest date. My question is this: Would I be better keeping this format and inserting multiple rows on each submit, or to have one row for all 81 variables ($name, 20 x Position, 20 x Artists, 20 x Titles, 20 x Labels.) I know that the latter will be easier to query. Also, without maintenance, the size of the table for the current method will get extremely large. Will that affect server performance? I am still a newbie, so plain explanations would be most appreciated. Thanks very much in advance. Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php