开发者

Design question about Activity model / table

开发者 https://www.devze.com 2023-02-03 15:02 出处:网络
I have got an activity model which keeps track of each users activity. In this model I\'ve got the following columns: id, user_id, media_id, type, created_at, updated_at

I have got an activity model which keeps track of each users activity. In this model I've got the following columns: id, user_id, media_id, type, created_at, updated_at

开发者_开发问答One activity I am particularly concerned about is the song view. For example. When a user clicks on a song, the song starts playing. At the same time this happens, my app creates an activity for this, each time the user views the song page.

This means I could keep a sort of history time-line for user activities. i.e.

Foobar listened to Song A 2 hours ago
Foobar listened to Song A yesterday
Foobar listened to Song B 2 days ago
etc

In the future, if the app/site gains a lot of popularity, will this in some ways affect the database performance? I am worried that this table will populate itself very fast just for each user that views a song. I can't help looking at the videos on youtube which has around 100k ++ views per video.

Should I be worried? Or is it all about adding indexes and making sure the db can scale in terms of memory and disk space?


I think the activity model does too much since you also store data, that is never needed.

      table
------------------------
user_id        int
media_id       int
listened_at    TIMESTAMP

I'm omitting the type since this should be in context of media_id

If you realy get many hits per view, a simple database would not be able to handle this. Even a devent database cluster might have problems with that. But I would not actually worry about these things at an early stage.

0

精彩评论

暂无评论...
验证码 换一张
取 消