Hello
I am building an application that will allow a user to record weekly activity over a 6 week period. Each week has 3 benchmarks to record against, here is an example:
Week 1
+------------+-----------+------------+-----------+
| Day | Minutes | Location | Miles |
+------------+-----------+------------+-----------+
| Monday | | | |
+------------+-----------+------------+-----------+
| Tuesday | | | |
+------------+-----------+------------+-----------+
| Wednesday | | | |
+------------+-----------+------------+-----------+
| Thursday | | | |
+------------+-----------+------------+-----------+
| Friday | | | |
+------------+-----------+------------+-----------+
| Saturday | | | |
+------------+-----------+------------+-----------+
| Sunday | | | |
+------------+-----------+------------+-----------+
This is repeated for each week up to 6.
In my flat table I have the following:
UserID | Username | Week 1 Day 1 Minutes | Week 1 Day 1 Location | Week 1 Day 1 Miles | Week 1 Day 2 Minutes | Week 1 Day 2 Location | Week 1 Day 2 Miles ETC...
X 7 for a week and then X 6 for the 6 weeks.
I am trying to figure out where my eliminations are, and what my separate tables would be. So far I have the following:
User Table
+------------+-----------+
| UserID | Username |
+------------+-----------+
| | |
+------------+-----------+
Activity Table
+------------+-----------+------------+-----------+------------+-----------+
| UserID | WeekID | Day | Minutes | Location | Miles |
+------------+-----------+------------+-----------+------------+-----------+
| | | | | | |
+------------+-----------+------------+-----------+------------+-----------+
Weeks Table
+------------+-----------+------------+
| UserID | WeekID | Week_No |
+------------+-----------+------------+
| | | |
+------------+-----------+------------+
I think I am getting along the right lines, but the Weeks Table doesn't seem right and I am not sure what the relationships are - I don't think I need UserID in each table, and I'm not sure what the PKs should be.
Any comments on this schema, or an efficient way to achieve the first normal form given the application requirements would be much appreciated, many thanks.
EDIT:
Thanks very much for all the answers, great stuff.
I think having a Location Table would be beneficial as I could standardize locations (could provide a list to choose from) and if I need to query based on location, I'll have consistent location names.
Revised the schema to this:
User Table - UserID PK
+------------+-----------+
| UserID | Username |
+------------+-----------+
| | |
+------------+-----------+
Activity Table - ActivityID PK
+------------+-----------+------------+-----------+------------+-------------+-----------+
| ActivityID | UserID | Week_No | Day | Minutes | LocationID | Miles |
+------------+-----------+------------+-----------+------------+-------------+-----------+
| | | | | | | |
+------------+-----------+------------+-----------+------------+-------------+-----------+
Location Table - LocationID PK
+------------+---------------+
| LocationID | Location_Name |
+------------+---------------+
| | |
+------------+---------------+
2nd EDIT:
I now have a question on 2NF and 3NF on this topic: