Best way to store X clicks/days in MySQL
I want to store my users clicks from the last 10 days in my database.
I have heard that storing it like this: "4;3;1;4;5;3;7;2;6;3" is a really bad idea, and it breaks the rules.
But, what 开发者_如何学JAVAbetter way is there to store clicks for this many days? For me, it would be insane to create 10 columns with each day clicks.
Please advice.
I'd store then in a table like this
userkey (PK, FK)
date (PK)
clicks
At some point, you'll be asked for "last 30 days" or "last year"
And it makes maintenance easier of managing 10 columns or trying to roll values
精彩评论