I'm trying to make a timekeeper and thinking about a good database structure.
The idea is the following:
On a frontend (e.g. Website, a Java-Application, what ever) you can create a timer with a specific name.
To keep the timekeeper running even if you close the frontend I thought of having a table, which keeps the starttime (as datetime).
And if you stop the timer the difference between starttime and the endtime would be the total spent time.
So far so good.
But I also want to add the possibility to continue a timer.
So I thought about having two tables.
One to keep the total time (with the columns "name" and "timeSpent") and one to keep each single "start-stop"-action.
So if you create a new timer it creates a new row in the first table with the name and a new row in the second table with the starttime.
If you then stop the timer, the time difference gets calculated and the first table will be updated (timespent = difference) (by using a procedure).
So that if you restart/continue the timer it should create again a new row in the second table and by stopping, again update the first table (timespent = timespent + difference).
Now the question is: Is this a good way, do I've missed something, or does someone have a better idea for this?