I pull monthly aggregate data from a SQL database. I store the aggregated data in a separate table in the same database (so I can quickly grab numbers from six months ago, for instance).
My issue is that sometimes I am asked to pull details about the data from six months ago, but in our system the data is super dynamic and if I were to re-calculate my data from six months ago, I'd get different numbers than I did when I originally ran the data (because the underlying data has changed).
Contrived example: Number of users whose last name begins with "A". This data can change over time if a user changes their name.
I see a few high-level options:
- Offload the details of the data each month into an excel spreadsheet, and save it in a file system (in the example above, we'd store a UserID and LastName) like UserNames-2022-04-01.xlsx
- Make a timestamped copy of the critical data (Timestamp, UserID and LastName) in a separate database table, and use that for my aggregating and historical analysis
- Similar to #2, but import the data into a data warehouse
I think the answer here is "Data Warehouse" but I want to be sure I am not missing a better/different approach.
Is there an approach that is considered best-practice in this scenario?
AS OF <date_time>
?