Reputation: 8131
I'm building something like Facebooks Wall inside of Rails. It will look something like this:
- Stacey S. Wants to be Friends
- You've been invited to the Summer Social
- Pat Replied to your Message: Hey!!!
- American Pet Society has a new Post: Love Your Cat!
There are two ways to do this. I could have each of these different events write to the events database when they are created or I could pull from the relationships, invitation, inbox and posts tables and create the events on the fly.
I'm leaning towards the events database approach because it seems cleaner to just call that one table than all the other tables and then sort them correctly. Is this how you would do it?
Upvotes: 1
Views: 481
Reputation: 4113
I'm building a system with similar requirements now, and I think you'll find that the performance characteristics of the latter approach make it extremely untenable. depending on how much usage you intend to get out of the system, you may find the event table to be a performance hog during the request as well. What I'm doing is using an architecture that's basically CQS with event sourcing which builds the feeds for a given user in the background and caches them in a thoroughly denormalized fashion to make the request cycle very short.
Another approach you should look at is using Chronologic: https://github.com/gowalla/chronologic. It may save you quite a bit of effort.
Upvotes: 3
Reputation: 14983
By all means, it will save you from a lot of complicated queries and sorting. Go for the event table approach.
Upvotes: 1