Agreed. There’s something not quite right about my approach, but I can’t pinpoint it. What you said about splitting by week could work, but that doesn’t seem quite right either. Any other ideas or know anyone else I could ask? I’m getting a little desperate.
-
- 22 Posts
OK, how’s about this
user table -> user_years table joined on user id
user_years table has columns user_year_id, year, user_id
Then you have a table for each week (you say the number is set in stone)
This would have a user_year_id as a foreign key so you could relate back to user and year
In each week table you would have columns week_id, user_year_id, stat_id, stat_value
with a lookup table to hold all the stat types with columns stat_id and stat_name
Will make your joins a little more complex but will only store the info relevant to each user, no more, no less.
Yeah, if I’m just saving the My BIGs data, I think I can do a single table, with one row per user and a column for each stat (I’ll probably still save to separate tables for each state to cut down the overhead a little). Since the user’s week-by-week stats are only going to be shown on their individual profile pages, I think I can store them however I want. The only issue would be down the road if the client wants to do week-by-week comparisons of users...hmm...
Regardless, I think I have a short-term solution, and some ideas for a better long-term solution. Thanks! If anyone comes up with just an absolute brilliant way to do this that hasn’t been mentioned yet, please let me know!
-
- 22 Posts
There is still some kind of inconsistency here because the bigs seem related to week on the last page you showed me yet there is nothing on the big entry interface that makes that obvious so you need to make sure you take account of that.
Oh, crud. Yes, the second-to-last link I sent does compare weekly. Looks like I’ll have to do this after all.
Care to take a swing at the PDO syntax for your suggested setup? ;-)