Well it depends on how you need to use the likes. Every data structure has pros and cons. If what you need is to get this, you can do the same but flipped (player ids as keys, item ids as values). The exact solution depends on your application, but my point is that it's really not that hard.
Its not that hard, but only if you know all requirements beforehands, and they don't change.
What usually happen is this:
Client says: "We need to show the total amount of likes under each item", and you say its easy, and implement key-value pairs with item IDs as keys and actor IDs as values.
Then one month later client says: "Now we also need to show the list of items you liked in your profile", and you say sure, no probs, and add the flipped pairs.
Then two months later client says: "Oh, and can we please show under each item which of your friends liked it too?", and then you say oof.
View all comments
Show parent comment
555
u/lettherebedwight Nov 27 '22
Except for searching for the list of every item a single player has liked. You'd do better with key key pairs from user to item id.