I need some advice…
I have an application where users can do certain actions.
For example, users can have friends.
So…
Users can see his friends activity.
So how should I implement the activity log in the DB?
Should I have a new table?
Can I do some queries from multiple table and sort a joined result?
I need some advice… I have an application where users can do certain actions.
Share
I suggest you create an activity_type table and a logs table.
Now you can easily maintain logs using the following table
User#15 added a new friend user#5 on 10th March.
User#15 added a new comment#19 on 10th March.
User#15 added a new image#84 on 10th March.
User#15 changed his display picture on 10th March.
UPDATE
There may be activities where object_id doesn’t make sense like- updated display image, updated profile info etc. Here you can possibly store diff of text in a separate column.
The same approach can be used for storing audit logs.