For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2004 > Best table structure









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Best table structure
Tom Chubb

2004-06-30, 8:56 am

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com