Preface: I’m developing an application that quizzes users on multiple topics. I wish to keep a history of their progress and be able to easily present the user with a daily,weekly and monthly view of their progress on a per topic basis.
The initial design for my table is as follows:
CREATE TABLE IF NOT EXISTS `user_topics` (
`ProgressID` int(11) NOT NULL,
`UserID` int(11) NOT NULL,
`TopicID` int(11) NOT NULL,
`Level` decimal(3,1) NOT NULL,
`TotalCorrect` int(11) NOT NULL,
`QuestionsAsked` int(11) NOT NULL,
`DateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`ProgressID`)
)
Am I going along the right lines/ how can I retrieve the data I need to provide a presentable history?
Edit:
I’d want to display a graph with time as a scale and % correct, this would be done when a user clicks to view their monthly/weekly progress for their topics. I would like the load time between viewing weekly/ monthly data per topic pretty transparent.
Should the data be retrieved in a single call(just select the rows with from date x until now) then then leave it up to the individual client to organise the data into days/months etc then present the data?
you can use date_between to query for all progress records betweentwo dates with something like this:
here is the mysql documentation for ‘between … and …’
So now, using some graphing tools, you could get all the progress for the last day/week/month/year and present their progress.