How should I design a dynamic database for users of social websites like QQ space?

Source: Internet
Author: User
I recently encountered several problems with similar functions: 1. dynamic type Diversity; 2. modular data storage, calling data between modules through rest, resulting in longer response time for pulling dynamic lists; 3. the data level is complex, and the encoding logic is less universal. For example, after forwarding an article, comment on the forwarding... a similar feature has recently encountered several problems:
1. Dynamic type diversity;
2. modular data storage. Calling Data through rest between modules leads to longer response time for pulling dynamic lists;
3. The data level is complex, and the encoding logic is less universal. For example, after an article is forwarded, the comment is forwarded, and the object level for replying to the comment is: reply-> comment-> Article.

Thank you for your experience!

The following are the existing designs:

Dynamic Structure:

{User_id: Dynamic creator ID, action: behavior type, object_type: Dynamic Object Type, object_id: Object ID, object_user: Object owner, view_count: 0, created_at: Creation Time, deleted_at: deletion time ,}

Scenario list:

// A published the article xxx 'action' => NEW, 'user _ id' => A's id, 'object _ id' => Article ID, 'object _ user' => A's ID, 'object _ type' => ARTICLE, 'text' => [], // A publishes N images 'action' => NEW, 'user _ id' => id of A, 'object _ id' => image ID (array, separated by commas), 'object _ user' => A's ID, 'object _ type' => PICTURE, 'text' => [], // 4. A raised the question xxxx 'action' => NEW, 'user _ id' => A's id, 'object _ id' => question ID, 'object _ user' => A's ID, 'object _ type' => QUESTION, 'text' => [], // 5. A replied to comment 'action' => REPLY, 'user _ id' => A's id, 'object _ id' => comment ID, 'object _ user' => B's ID, 'object _ type' => COMMENT, 'text' => ['text' => $ text, 'comment _ target_id '=> 'Article id', // comment object 'comment _ target_type' => 'Article ', // comment object type 'reply _ id' => reply id,], // 6. A commented on article xxxx 'action' => COMMENT, 'user _ id' => A's id, 'object _ id' => Article ID, 'object _ user' => B's ID, 'object _ type' => 'Article ', 'text' => ['comment _ id' => 'comment id',], // 7. A answered B's question xxx 'action' => RESPOND, 'user _ id' => A's id, 'object _ id' => question ID, 'object _ user' => B's ID, 'object _ type' => QUESTION, 'text' => ['answer _ id' => 'answer id',],

Reply content:

I recently encountered several problems with similar functions:
1. Dynamic type diversity;
2. modular data storage. Calling Data through rest between modules leads to longer response time for pulling dynamic lists;
3. The data level is complex, and the encoding logic is less universal. For example, after an article is forwarded, the comment is forwarded, and the object level for replying to the comment is: reply-> comment-> Article.

Thank you for your experience!

The following are the existing designs:

Dynamic Structure:

{User_id: Dynamic creator ID, action: behavior type, object_type: Dynamic Object Type, object_id: Object ID, object_user: Object owner, view_count: 0, created_at: Creation Time, deleted_at: deletion time ,}

Scenario list:

// A published the article xxx 'action' => NEW, 'user _ id' => A's id, 'object _ id' => Article ID, 'object _ user' => A's ID, 'object _ type' => ARTICLE, 'text' => [], // A publishes N images 'action' => NEW, 'user _ id' => id of A, 'object _ id' => image ID (array, separated by commas), 'object _ user' => A's ID, 'object _ type' => PICTURE, 'text' => [], // 4. A raised the question xxxx 'action' => NEW, 'user _ id' => A's id, 'object _ id' => question ID, 'object _ user' => A's ID, 'object _ type' => QUESTION, 'text' => [], // 5. A replied to comment 'action' => REPLY, 'user _ id' => A's id, 'object _ id' => comment ID, 'object _ user' => B's ID, 'object _ type' => COMMENT, 'text' => ['text' => $ text, 'comment _ target_id '=> 'Article id', // comment object 'comment _ target_type' => 'Article ', // comment object type 'reply _ id' => reply id,], // 6. A commented on article xxxx 'action' => COMMENT, 'user _ id' => A's id, 'object _ id' => Article ID, 'object _ user' => B's ID, 'object _ type' => 'Article ', 'text' => ['comment _ id' => 'comment id',], // 7. A answered B's question xxx 'action' => RESPOND, 'user _ id' => A's id, 'object _ id' => question ID, 'object _ user' => B's ID, 'object _ type' => QUESTION, 'text' => ['answer _ id' => 'answer id',],

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

Finally, I made adjustments based on open source China to meet our needs:

Dynamic Structure:

{User_id: 13, action: behavior, object_id: Object ID, object_type: object type, object_user_id: Object User ID, parent_object_id: Object parent ID, parent_object_type: Object parent type, parent_object_user_id: the parent user ID of the object, reply_id: reply ID, // parent_reply_id: reply parent reply ID, // action is used for reply, replied to others' comments. text: 'additional text when forwarding or sharing ', view_count: 0, created_at: Creation Time, deleted_at: Deletion time ,}

Note:
1.object_*Only content of the main module is stored, without comments;
2.parent_object_*Stores nested objects, such as whenobject_*When the answer is,parent_object_*For the problem;
3.reply_idUsed to directly reply to comments;
4.parent_reply_idParent reply ID;
5. Two reply IDs. Usage: when someone else repliescomment_idPull comments and all replies. Only two replies of the conversation are displayed when the template is displayed.

Scenario list:

Level 1 structure:

  • Anzhengchao ReleaseNowArticle

'Action' => NEW, 'user _ id' => anzheng Chao id, 'object _ id' => Article ID, 'object _ user_id '=> anzheng Chao id, 'object _ type' => ARTICLE,
  • Anzhengchao UploadNImage

'Action' => NEW, 'user _ id' => anzheng Chao id, 'object _ id' => image ID (array, separated by commas ), 'object _ user_id '=> anzheng Chao ID, 'object _ type' => PICTURE,
  • AnzhengchaoMentionedProblemXxxx

'Action' => NEW, 'user _ id' => anzheng Chao id, 'object _ id' => problem ID, 'object _ user_id '=> anzheng Chao id, 'object _ type' => QUESTION

Level 2 structure:

  • Anzhengchao CommentNowArticleXxxx (AnswerGeneral)

Demonstration: article: xxxxx comment: xxxxx (Commented by Li Lin)

'Action' => COMMENT, 'user _ id' => anzheng Chao id, 'object _ id' => comment id, 'object _ type' => COMMENT, 'object _ user_id '=> anzheng Chao ID 'parent _ object_id' => article id, 'parent _ object_user_id '=> Author ID 'parent _ object_type' => ARTICLE,

Three-level structure:

  • AnzhengchaoInArticleMediumReplyNowLi LinOfComment

Demonstration: article: xxxxx comment: xxxxx (Commented by Li Lin) reply: xxxx (anzhengchao)
'Action' => REPLY, 'user _ id' => anzheng Chao id, 'object _ id' => comment id, 'object _ type' => COMMENT, 'object _ user_id '=> Lilin ID' parent _ object_id '=> article id, 'parent _ object_user_id' => Author ID 'parent _ object_type' => ARTICLE, 'reply _ id' => anzhengchao's reply id

Level 4 structure:

  • Anzhengchao ReplyNowLi WenkaiInProblem"Xxxx"Li LinOfAnswerUnderComment

Notes: The question information is retrieved from the answer interface.


Demonstration: Question: xxxxx answer 1... answer 2... answer 3... (replied by Li Lin) Comment: xxxxx (Commented by Li Wenkai) reply: xxxx (anzhengchao)

'Action' => RESPOND, 'user _ id' => anzheng Chao id, 'object _ id' => comment id, 'object _ type' => COMMENT, 'object _ user_id '=> Li Wenkai's ID 'parent _ object_id' => answer id, 'parent _ object_type '=> ANSWER, 'parent _ object_user_id '=> Lilin ID' reply _ id' => anzhengchao's reply id
  • Anzhengchao ReplyNowLi WenkaiInProblem"Xxxx"Li LinOfAnswerUnderReply

Notes: The question information is retrieved from the answer interface.


Demonstration: Question: xxxxx answer 1... answer 2... answer 3... (replied by Li Lin) Comment: xxxxx (Commented by A) Li Wenkai reply A: xxxx anzhengchao reply Li Wenkai: xxxx

'Action' => RESPOND, 'user _ id' => anzheng Chao id, 'object _ id' => comment id, 'object _ type' => COMMENT, 'object _ user_id '=> A's ID 'parent _ object_id' => answer ID, 'parent _ object_type '=> QUESTION, 'parent _ object_user_id' => Li Lin ID, // The following two replies are only used in the template to determine which two replies are to be displayed, because 'parent _ reply_id '=> Li Wenkai's reply ID will be pulled back Based on the comment_id, 'reply _ id' => anzhengchao's reply id,

Thank you for your correction!

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

How to get the content information of different modules? You can only find the id in this table, but there is no specific content.

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.