best practice in mysql?
I need to store historical 开发者_StackOverflow社区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?
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 {} \;
You should create table history with columns (data, date) if I understood correctly.
精彩评论