什么是执行一项社会活动流的最佳方式? [英] What's the best manner of implementing a social activity stream?

查看:124
本文介绍了什么是执行一项社会活动流的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣听你的意见,这是实施社会活动流(Facebook是最有名的例子)的最佳方式。所涉及的问题/挑战是:

I'm interested in hearing your opinions in which is the best way of implementing a social activity stream (Facebook is the most famous example). Problems/challenges involved are:

  • 在不同类型的活动(张贴,评论...)
  • 在不同类型的对象(职位,评论,照片..)
  • 参与不同的角色
  • 1-n个用户(用户X回答用户Y的评论对用户的Z后)
  • 在同一活动项目的不同视图(你评论..与你的朋友x评论与用户X评论...的评论活动=> 3重presentations)
  • Different types of activities (posting, commenting ..)
  • Different types of objects (post, comment, photo ..)
  • 1-n users involved in different roles ("User x replied to User y's comment on User's Z post")
  • Different views of the same activity item ("you commented .." vs. "your friend x commented" vs. "user x commented .." => 3 representations of a "comment" activity)

..和更多一些,特别是如果你把它给复杂的高层次,像Fac​​ebook那样,例如,几个活动项目合并成一个(用户X,在该照片y和z评论

.. and some more, especially if you take it to a high level of sophistication, as Facebook does, for example, combining several activity items into one ("users x, y and z commented on that photo"

在任何模式,纸张等上最灵活,高效,功能强大的方法来实现这样的系统,数据模型等想法或指针将AP preciated。

Any thoughts or pointers on patterns, papers, etc on the most flexible, efficient and powerful approaches to implementing such a system, data model, etc. would be appreciated.

虽然大多数问题是平台无关的,很可能是我最后on Rails的实施上的Ruby这样的系统

Although most of the issues are platform-agnostic, chances are I end up implementing such a system on Ruby on Rails

推荐答案

我建立了一个这样的系统,我把这种方式:

I have created such system and I took this approach:

数据库表具有以下列:ID,用户id,类型,数据,时间

Database table with the following columns: id, userId, type, data, time.

  • 用户id 是谁产生的活动的用户
  • 键入是活动的类型(即写了一篇博客文章,添加照片,评论用户照片)
  • 数据与元数据的活动序列化对象,你可以把任何你想
  • userId is the user who generated the activity
  • type is the type of the activity (i.e. Wrote blog post, added photo, commented on user's photo)
  • data is a serialized object with meta-data for the activity where you can put in whatever you want

这限制了搜索/查找,您可以在饲料办,给用户,时间和活动类型,但是在一个Facebook式活性饲料,这是不是真的限制。并与表正确索引的查找是的快速的。

This limits the searches/lookups, you can do in the feeds, to users, time and activity types, but in a facebook-type activity feed, this isn't really limiting. And with correct indices on the table the lookups are fast.

有了这个设计,你必须决定哪些元数据每种类型的事件应要求。例如,对于一个新的照片饲料的活动可能看起来是这样的:

With this design you would have to decide what metadata each type of event should require. For example a feed activity for a new photo could look something like this:

{id:1, userId:1, type:PHOTO, time:2008-10-15 12:00:00, data:{photoId:2089, photoName:A trip to the beach}}

您可以看到,虽然照片的名字肯定是存储在其它表包含的照片,我可以从那里获取的名字,我会重复的元数据字段的名称,因为你不想要做其他数据库表中的任何连接,如果你想要的速度。而为了显示,说从50个不同的用户200,不同的事件,你需要的速度。

You can see that, although the name of the photo most certainly is stored in some other table containing the photos, and I could retrieve the name from there, I will duplicate the name in the metadata field, because you don't want to do any joins on other database tables if you want speed. And in order to display, say 200, different events from 50 different users, you need speed.

然后,我有类呈现不同类型的活动条目延伸基本FeedActivity类。事件的分组将建造在渲染code还有,要远离复杂的数据库。

Then I have classes that extends a basic FeedActivity class for rendering the different types of activity entries. Grouping of events would be built in the rendering code as well, to keep away complexity from the database.

这篇关于什么是执行一项社会活动流的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆