Create another table to store information from the users and posts tables:
CREATE TABLE votes ( user_id INT , post_id INT , PRIMARY KEY (user_id, post_id) );
With this approach:
I thought of having a column in the posts that would store the uids of the users who voted for it. Another idea would have columns for users with the identifiers of the posts he voted on.
If you donβt save the values ββas separation values ββ(to fit in one cell) or JSON, you will get many rows in just one message. But then this is a bad approach to begin with.
Stick to creating a new table containing the relationships that define the "vote". The table is simple enough to check:
SELECT COUNT(t1.post_id) AS vote_count FROM votes AS t1 WHERE t1.user_id = SOME_INTEGER AND t1.post_id = SOME_INTEGER
source share