I want to create an inventory system for an online multiplayer game, so I was thinking about database.

My research led me to this form:

  • id (user, bigint, unsigned + index, foreign key for user's id in users table)

  • itemid (item_id, int, unsigned)

  • amount (amount of the items, int)

I know there will be a lot of rows with duplicated user IDs - are there any improvements I can make to this design to work with that?

  • \$\begingroup\$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. \$\endgroup\$
    – Community Bot
    Aug 31 at 13:17
  • \$\begingroup\$ Done. Hopefully it's better now. \$\endgroup\$
    – Gamer
    Aug 31 at 13:21

A lot of rows is not a problem per se, even more so since you do not neet to ask for the whole inventory all the time - it should be enough to get the full inventory once at the start of the game and keep it locally at your player and just do another check on the server once the player actually uses an item (to prevent client side manipulation of item amount).

Before you encounter an actual bottleneck (which is unlikely to be the database), your approach seems to be ok.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.