Reputation: 1043
So I am stuck on a decision:
I am deciding wether to do something like this for a user activity feed:
id | userID | typeID | contentID | time
OR something more relational with foreign keys and proper indexing like this:
id | userID | postID | postCommentID | photoID | photoCommentID | time
Or along those lines.
I am looking for an answer which doesn't just say which one but also why and the advantages/disadvantages.
EDIT:
Another thing this applies to is wether using 1 comment table with type | contentID
or postID | photoID
is better OR 2 separate tables; one for photo comments and one for post comments??
EDIT 2:
How the data would be used:
It could be used in 2 scenarios - For displaying in a time line feed for the user themselves or other users around them.
EDIT 3:
The reason for choosing this method to create activity feeds even though all the detailed info is stored in other tables is for speed when loading feeds, although I understand I am sacrificing write performance. It also allows for me to add new data/post types later and reduces the number joins in my query to 0.
Thanks for your time!
-Stefan
Upvotes: 2
Views: 1505
Reputation: 89661
When you say feed - you mean for someone else's consumption? Or for storing someone else's feed? Or just a person's activity in your system?
I would normalize first, denormalize as you need to later, but neither of your options show the full story of the scope of what you are modeling.
Upvotes: 1