mardi 5 juillet 2016

Mysql : table strucutre design for post 'like' and 'unlike'

I have an android app which a user can "like/unlike" a post,

I have created a table:

| id | post_id | user_id |
|  1 |     105 |      67 |
|  2 |      76 |      56 |
|  3 |      36 |     102 |

with id auto-increment, is this table structure correct?

since one person can like/dislike multiple times, do you think deleting the row (unlike) + create new row (like) is good practice?

The auto-increment row will increase and reached big numbers if there are many users, is this bad? since the auto-increment cannot reuse the deleted row.

if I added an extra boolean column, like with value 1 or 0

and consider a user without an existing row in the table + user with an existing row but column like = 0 as unlike

will that be better?

Aucun commentaire:

Enregistrer un commentaire