galvin Posted November 21, 2014 Share Posted November 21, 2014 I am still trying to fully comprehend table normalization and I'm not asking anyone to explain it bc it's not a simple thing to explain. But I'm working on a football website that tracks players stats each week (catches, yards and touchdowns) and it seems like setting it up this way would make it the easiest (maybe laziest?) to retrieve data to display wherever I want... tablecalled players with these fields: playerid playerfirstname playerlastname week1catches week1yards week1touchdowns week2catches week2yards week2touchdowns ... and so on 17 times till... ... week17catches week17yards week17touchdowns I know that is likely making most of you want to puke but if doing it this way makes it extremely easy to pull this info for display on the site, why is it so wrong? Is the problem that it's much slower than what I THINK is the proper way, ie... table called players with these fields: playerid playerfirstname playerlastname AND table called stats with these fields: playerid week catches yards touchdowns Again, not asking for an explanation of normalization, just if anyone has any quick reasons why the first way is as god awful as I fear it is, I'd appreciate the knowledge. Thanks! Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted November 21, 2014 Share Posted November 21, 2014 makes it extremely easy to pull this info for display on the site it doesn't even do that, since you either have to hard-code each field reference or build a dynamic reference to access the incrementing field names. what if you are trying to get the total of any field, i.e. total yards? you have to write a bunch of php code or a verbose query listing all the relevant fields to do it. by normalizing the data, you can do a simple SUM() in a query to get the same result. 1 Quote Link to comment Share on other sites More sharing options...
galvin Posted November 21, 2014 Author Share Posted November 21, 2014 Good point, mac_gyver, thank you. So at the end of the day, there is really no situation where doing it the first way would make any sense, right? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted November 21, 2014 Share Posted November 21, 2014 no case that i can think of. even if you only have two same meaning fields spread out in a row, it results in more code to find or manipulate the correct piece of data. this boils down to the granularity of the data. normalized data stores each piece of same meaning data in its own row. as a result, you can easily find or manipulate any amount of the data, be it one piece, a specific sub-set of the data, or all the data. 1 Quote Link to comment Share on other sites More sharing options...
galvin Posted November 21, 2014 Author Share Posted November 21, 2014 Cool, very easy to understand explanation. Some of the normalization stuff I'm reading is making my head explode. Thanks again for your thoughts! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.