How can I design the intra-site message prompting function, such as segmentfault? I am releasing a question. After someone answers the question, I will receive a reminder about the number of unread messages. How can I design a data table appropriately? How can I design the intra-site message prompting function, such as segmentfault? I am releasing a question. After someone answers the question, I will receive a reminder about the number of unread messages. How can I design a data table appropriately?
Reply content:
How can I design the intra-site message prompting function, such as segmentfault? I am releasing a question. After someone answers the question, I will receive a reminder about the number of unread messages. How can I design a data table appropriately?
Notice_code is defined in the Code, and a notification information template is also defined.
Public static $ notice_type = ['ancer' => ['is _ agreed '=> [500,' [who] liked your answer! '], 'Is _ modified' => [501,' [who] modified your answer! '], 'Is _ fold' => [502,' [who] fold your answer! '], 'Has _ new_comment' => [503, '[who] commented on your answer! '],],];
In the comparison, 503 indicates a comment notification. When someone comments an answer, the required parameter is: who
In the notification list, first determine the notification code, find the corresponding template, and convert the variable [who] based on the corresponding parameters.
We have a preliminary plan just now. Please try it out:
There are two main tables:
Question: Table of problem information
Id (autoincrement) user_id (User ID for posting the question) question_id (problem id (unique in the system) question_desc (Problem description) like_user_list (like user list, user_id uses ',)
Reply:
Id (autoincrement) user_id (User id for answering questions) question_id (with question_id as a foreign key in question) reply_content (comment content) like_user_list (like user list, user_id used ', 'split) unlike_user_list (ID list of the target user)
The procedure is as follows:
1. Insert a record to question when you publish a question;
2. When others comment on this issue, insert a record to reply
3. If someone else thinks this is a good question, like this question or reply and append the corresponding like_user_list
Areas to be further improved:
(1) Record of comments reply
I will not talk about how to design database tables. What I want to talk about is that the reminder class is not suitable for storing tables. Generally, it is impossible for me to cache data. Every time I refresh it, I go to the table and count it again. This data goes directly to the cache. more efficient