I'm working on a zend project which has functionality based on user logged minutes. It needs to be able to generate reports based on date ranges. I'm hoping someone can help me figure out the best way to handle storing that information.
I am using a users table to handle all of the essential profile information. I would imagine the best case would be to link this to another table to track the minutes... im just not wrapping my mind around how it should lay out. I have seen some pages that suggest using columns in the database for the dates but that seems to me like it would become unmanageable quickly.
With the current site at 1500 users and multiple users submitting every day... im just not sure how id go about it.
Any help would be great. Thanks
One approach, based on what I think you're looking for:
Create a User_Session table containing a User_ID FK, a Start_Time, and an End_Time. Write a new row to this table every time a user starts and ends a session. You can grab these User_ID and Start_Time at login, and grab End_Time when the session ends or the user logs off.
Now you've got a historical table with [1500 users] x [number of sessions per day] which I'd call large but not unimaginably so. (Especially seeing how it's properly indexed and so forth.) You can run queries against that table, something like SELECT User_ID, SUM(End_Time - Start_Time) so to speak, against whatever date ranges you need.
To control the table size, you could in turn store these aggregated values (User_ID, MMYY, Num_Minutes) and truncate the source table on some set schedule. Storing calculated fields may not preferable to having the normalized data on hand, though. So maybe don't go that route until you've determined that the source table size is a big issue.
Just one of many ways, and oversimplified for clarity's sake.