I have a site written in cakephp with a mysql database.
Into my site I want to track the activities of every users, for example (like this site) if a user insert a product I want to put this activity into my database.
I have 2 ways:
1) One table called Activities with:
– id
– user_id
– title
– text
– type (the type of activity: comment, post edit)
2) more table differenced by activities
– table activities_comment
– table activities_post
– table activities_badges
The problem is when I go to the page activities of a user I can have different type of activities and I don’t know which of this solution is better because a comment has a title and a comment, a post has only a text, a badge has an external id to its table (for example) ecc…
Help me please
I’m not familiar with CakePHP, but from purely database perspective your data model should probably look similar to this:
The
symbol denotes category (aka. inheritance, subclass, subtype, generalization hierarchy etc.). Take a look at “Subtype Relationships” in ERwin Methods Guide for more info.
There are generally 3 strategies for implementing the category: