I fear I don't know what I'm doing.
1:
I have a table called ticket
which has a column called total
. When the total is updated I want to keep a record of it (old total, etc), so I decided to remove the total
column and create a table called ticket_total
with columns ticket_id
, total
, and datetime
(the most recent of course is the "current" total).
or
2:
Then I realized that I will later want to give my clients the ability to sort tickets by total
, or pull reports that aggregate the totals, etc. So, I decided instead to put back the total
column on ticket
, and to change the total
column directly when the total is updated, but first create a ticket_total
row as a record of the previous total
.
It seems that version 2 would be highly efficient because I wouldn't need to query the related ticket_total
table as much, but I wonder what you DB gurus out there think. I'm just learning database design and fear I'm never going to be good at it.