I want to record some type of user's activity, i.e, a user login, or publish a new post.
I come up two way to do this in database:
1, create an Activity table
activity_type [enum of activity type]
meta_data
use meta_data to store the info of specified activity. But I can only store meta_data as string for objects, and seems not efficient to do query with filter.
2, create a table for every type of activity
# loginActivity
time
ip
# publishActivity
post_id
user_id
The problem of this way is if there is a new type of activity I want to record, a new table should be created.
Which way is more suitable for this situation? Or is there a better way to do this?