How should the user dynamic database of social networking sites like QQ space be designed?

Source: Internet
Author: User
Recently in doing similar functions, encountered several problems:
1. dynamic type diversity;
2. Data modularization storage, the data is called by rest between the modules, which causes the response time of the pull dynamic list to become longer;
3. The data level is complex and the coding logic is poor. For example, after forwarding an article, commenting on the forward, and then replying to the comment, the object level is: reply, comments, and articles.

For those who have relevant experience to share the experience to thank!

The following are the existing designs:

Dynamic structure:

 {      user_id: 动态创建者ID,      action: 行为类型,      object_type: 动态对象类型,      object_id: 对象ID,      object_user: 对象所有者,      view_count: 0,      created_at: 创建时间,      deleted_at: 删除时间, }

Scene List:

A released the article xxx ' action ' + NEW, ' user_id ' and A's ID, ' object_id ' = Article ID, ' Object_user ' and ' A ' id, ' objec    T_type ' + article, ' ext ' = = [],//a released N-Pictures ' action ', ' + new ', ' user_id ' and A's ID, ' object_id ' = = Picture ID (array, separated by commas), ' object_user ' and ' A ' id, ' object_type ' = ' = ', ' ext ' = = [],//4. A raised the question xxxx ' action ' = NEW, ' user_id ' and ' A ' id, ' object_id ' = Problem id, ' object_user ' and ' A ' id, ' Object_typ E ' = QUESTION, ' ext ' = = [],//5. A in the article replies to the B's comment ' Action ' and ' REPLY ', ' user_id ' and ' A ' id, ' object_id ' + Comment ID, ' object_user ' and ' = B ' id, ' OB Ject_type ' + COMMENT, ' ext ' = = [' text ' + = $text, ' comment_target_id ' + ' article ID ',//comment on the object ' Comment_ Target_type ' = ' article ',//comment on the object type ' reply_id ' = Reply ID,],//6. A commented on the B's article xxxx ' action ' = COMMENT, ' user_id ' and A's ID, ' object_id ' = Article ID, ' Object_user ' and ' B ' id, ' O Bject_type ' = ' article ', ' ext ' => [' comment_id ' = ' comment id ',],//7. A answered B's question xxx ' action ' + RESPOND, ' user_id ' and A's ID, ' object_id ' = Problem id, ' object_user ' and ' B ' id, ' O   Bject_type ' + QUESTION, ' ext ' = = [' answer_id ' = ' answer ID ',],

Reply content:

Recently in doing similar functions, encountered several problems:
1. dynamic type diversity;
2. Data modularization storage, the data is called by rest between the modules, which causes the response time of the pull dynamic list to become longer;
3. The data level is complex and the coding logic is poor. For example, after forwarding an article, commenting on the forward, and then replying to the comment, the object level is: reply, comments, and articles.

For those who have relevant experience to share the experience to thank!

The following are the existing designs:

Dynamic structure:

 {      user_id: 动态创建者ID,      action: 行为类型,      object_type: 动态对象类型,      object_id: 对象ID,      object_user: 对象所有者,      view_count: 0,      created_at: 创建时间,      deleted_at: 删除时间, }

Scene List:

A released the article xxx ' action ' + NEW, ' user_id ' and A's ID, ' object_id ' = Article ID, ' Object_user ' and ' A ' id, ' objec    T_type ' + article, ' ext ' = = [],//a released N-Pictures ' action ', ' + new ', ' user_id ' and A's ID, ' object_id ' = = Picture ID (array, separated by commas), ' object_user ' and ' A ' id, ' object_type ' = ' = ', ' ext ' = = [],//4. A raised the question xxxx ' action ' = NEW, ' user_id ' and ' A ' id, ' object_id ' = Problem id, ' object_user ' and ' A ' id, ' Object_typ E ' = QUESTION, ' ext ' = = [],//5. A in the article replies to the B's comment ' Action ' and ' REPLY ', ' user_id ' and ' A ' id, ' object_id ' + Comment ID, ' object_user ' and ' = B ' id, ' OB Ject_type ' + COMMENT, ' ext ' = = [' text ' + = $text, ' comment_target_id ' + ' article ID ',//comment on the object ' Comment_ Target_type ' = ' article ',//comment on the object type ' reply_id ' = Reply ID,],//6. A commented on the B's article xxxx ' action ' = COMMENT, ' user_id ' and A's ID, ' object_id ' = Article ID, ' Object_user ' and ' B ' id, ' O Bject_type ' = ' article ', ' ext ' => [' comment_id ' = ' comment id ',],//7. A answered B's question xxx ' action ' + RESPOND, ' user_id ' and A's ID, ' object_id ' = Problem id, ' object_user ' and ' B ' id, ' O   Bject_type ' + QUESTION, ' ext ' = = [' answer_id ' = ' answer ID ',],

http://www.oschina.net/question/12_70587 This is more in line with my problem.

Finally, I refer to open source China to make adjustments to fulfill our needs:

Dynamic structure:

 {      user_id:13,      action: 行为,      object_id: 对象ID,      object_type: 对象类型,      object_user_id: 对象用户ID,      parent_object_id: 对象父级ID,      parent_object_type: 对象父级类型,      parent_object_user_id: 对象父级用户ID,      reply_id: 回复ID,    // action为回复时有用      parent_reply_id: 回复的父级回复ID,       // action为回复时有用,回复了别人对评论的回复      text: '转发或者分享时附加文字',      view_count: 0,      created_at: 创建时间,      deleted_at: 删除时间, }

Description
1. object_* only the main module content information is stored, not including comments;
2. parent_object_* store objects that have nested relationships, such as when the object_* answer is the parent_object_* question;
3. reply_id used to respond to comments directly;
4. parent_reply_id parent reply ID;
5. Two reply ID, usage is: When replying to someone else's reply, according to comment_id pull comments and all replies, when the template display only two replies to the dialog.

Scene List:

First-Class structure:

    • Ang Sul published the article

'action' => NEW,'user_id' => 安正超ID,'object_id' => 文章ID,'object_user_id' => 安正超ID,'object_type' => ARTICLE,
    • Ang Sul uploaded N photos

'action' => NEW,'user_id' => 安正超ID,'object_id' => 图片ID(数组,以逗号隔开),'object_user_id' => 安正超ID,'object_type' => PICTURE,
    • Ang Sul raised the question xxxx

'action' => NEW,'user_id' => 安正超ID,'object_id' => 问题ID,'object_user_id' => 安正超ID,'object_type' => QUESTION

Secondary structure:

    • Ang Sul commented on the article xxxx ( answered the general)

展示: 文章: xxxxx 评论:xxxxx (李林评论的)

'action' => COMMENT,'user_id' => 安正超ID,'object_id' => 评论ID,'object_type' => COMMENT,'object_user_id' => 安正超ID'parent_object_id' => 文章ID,'parent_object_user_id' => 作者ID'parent_object_type' => ARTICLE,

Level Three structure:

    • Ang Sul replied to Li Lin 's comments in the article

展示: 文章: xxxxx 评论:xxxxx (李林评论的) 回复:xxxx (安正超)
'action'         => REPLY,'user_id'        => 安正超ID,'object_id'      => 评论ID,'object_type'    => COMMENT,'object_user_id' => 李林ID'parent_object_id'      => 文章ID,'parent_object_user_id' => 作者ID'parent_object_type'    => ARTICLE,'reply_id'       => 安正超的回复ID

Level four structure:

    • Ang Sul reply to Li Wenkei in the question "xxxx" Li Lin the answer under the comments

Description: Problem information retrieved from the answer interface


展示: 问题: xxxxx 答案1... 答案2... 答案3...(李林回答的) 评论:xxxxx (李文凯评论的) 回复:xxxx (安正超)

'action' => RESPOND,'user_id' => 安正超ID,'object_id' => 评论ID,'object_type' => COMMENT,'object_user_id' => 李文凯的ID'parent_object_id' => 答案ID,'parent_object_type' => ANSWER,'parent_object_user_id' => 李林ID'reply_id' => 安正超的回复ID
    • Ang Sul reply to Li Wenkei in the question "xxxx" Li Lin answer under the reply

Description: Problem information retrieved from the answer interface


展示: 问题: xxxxx 答案1... 答案2... 答案3...(李林回答的) 评论:xxxxx (A评论的) 李文凯 回复 A:xxxx 安正超 回复 李文凯:xxxx

'action' => RESPOND,'user_id' => 安正超ID,'object_id' => 评论ID,'object_type' => COMMENT,'object_user_id' => A的ID'parent_object_id' => 答案ID,'parent_object_type' => QUESTION,'parent_object_user_id' => 李林ID,// 以下两个回复只在模板中用到用以决定显示哪两个回复,因为根据comment_id带着回复会全部拉回来'parent_reply_id' => 李文凯的回复ID,'reply_id' => 安正超的回复ID,

You are welcome to correct me!

This is what you want, http://blog.csdn.net/java2king/article/details/6010250.

How to get different module content information, you this query this table, can only detect the ID, and no specific content

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.