What's the best practice approach to storing historical records?
I have an entity whose rows will constantly get updated. I need to keep track of each row's history. There will be about 40K "current" records at any given time and each of them will be updated on a daily basis for about 60 days, then the updates will stop.
I see two options here:
All current and historical records in one table - since each row will have an id that will allow me to identify which records are part of the same group.
Current and historical records in separate tables - each time the current record is updated, a copy of it pre-update is put into the history table. The history table would have a FK.
Is there another option I haven't considered? Which option is the more appropriate approach to what I am trying to do?
TRIGGERsonCurrentto add toHistorical. – Rick James Mar 09 '16 at 01:20UNIONto get current and historical. Is that generally a bad idea? – DatabaseNewbie Mar 11 '16 at 00:31UNIONis more expensive (in CPU cycles and code complexity) than a select from a single table. However, repeating current data in both the current and historical tables is more expensive (in hard disk) than keeping them separate. Where is your sensitivity and how would you strike this balance? I prefer simpler code which is more responsive. That's my bias. What is yours? (i.e. you have to decide based on your circumstances) – Joel Brown Mar 11 '16 at 02:04