I need to store historical data for something in mysql (only last 7 days) – should I just make an extra column for each or what is the acceptable way to?
Advertisement
Answer
if you want to store historical data for last 7 days only,
add a date-time column to store the record creation time-stamp,
and setup a cronjob to periodically remove the records which old than 7 days
if you are using file-based data (csv),
make sure categories data into different date,
and each file contains a single date,
use the find command to remove (I assume you are using linux)
find -type f -mtime 7 -xargs rm {} ;