【发布时间】:2012-02-24 00:43:39
【问题描述】:
我正在使用问题中的建议实现活动提要的设计:How to implement the activity stream in a social network
如果我有这样的架构,我如何才能最好地查询活动可能具有相应标签的活动提要(这意味着我需要加入一些其他表来获取标签数据)。
示例:
Activity 1: user4 tagged publication with tag1, tag2, tag3
Activity 2: publication rated 3 by user2
Activity 3: publication subscribed to by user9`
活动表:
id
user_id (int)
activity_type (tinyint)
source_id (int)
parent_id (int)
parent_type (tinyint)
time (datetime but a smaller type like int would be better)
我对如何实现这一点的想法是:
1. 使用 LEFT JOIN 进行 1 次查询,然后使用 javascript 将标签分配给相应的活动。
或者
2. 将标签作为 JSON 存储在数据库字段中
【问题讨论】:
标签: javascript mysql json