Implemented Storage likes in the separate table

infis

Well-known member
Now likes are stored together with posts in the form of a field of type BLOB. On the one hand it is reasonable, as allows to store set of the data practically without redundancy. On the other hand such storage does not allow to use this data in mathematical operations in queries. It essentially restricts usefulness of the given possibility.

If to store likes in the separate table, it creates one more superfluous query. But at the same time allows:
1. To produce mathematical operations in queries (for an example: SUM, MAX)
2. Adds possibility of usage not only "Likes", but also "Unlike". Now is only "Likes" also anything. System of pluses/minuses.
3. It is possible to select separately a thread (the first post in a thread) and other posts.
4. The extension of the rights for usage likes it is possible to achieve restriction of maximum usage like per hour, per day etc. Also it is possible to disconnect, for example, usage in some thread or a forum "Likes" or only "Unlike". Combinations there can be a set.
5. The aforesaid as a result allows to create rating system.
6. It is possible at review of the list by that at once to select threads which typed the greatest quantity of pluses.
7. Etc.

Thus, in the table xf_likes should be stored:
like_id
user_id
thread_id
post_id
like_date
like_value
like_notice
 
Upvote 0
This suggestion has been implemented. Votes are no longer accepted.
there's 1 problem with your db schema;)

likes aren't limited to posts...
you can use them for every content type, so it's not possible to have thread_id, post_id
you'll need content_type_id.... BUT before i describe it...:P , check table xf_liked_content
isn't this what you want;)
 

Attachments

  • likeschema.webp
    likeschema.webp
    13.8 KB · Views: 10
Yup, xf_liked_content is exactly the suggestion. The blob is for the last X likes and most and is not the canonical value anyway.
 
:oops:
I'm stupid. I'm sorry...

How it is possible to receive quickly an amount likes threads in the list of forums (it is necessary to display an amount near to reviews)? As it is necessary to know an amount likes each post of a thread except for the first post (it is necessary to display a rating of each post).
Well and the last question: how it is possible to deliver a minus (disapproval) to a post?
 
Top Bottom