Best way to store user "inventory"

If you had a table of users, and the user had to have a set of owned “items” like swords and guns etc, is it better to throw them all into an array on the user object or put the items in their own table with a reference to the owner user, and join the table.


It depends :slight_smile:
In my opinion if your inventory is going to maintain a 1 to many relation (user has items that can only belong to her) you could keep an array of them within the user document only if this does not have the risk to exceed the maximum document size of 16MB.
If it’s a single inventory for all users and users can share ownership I could still think of an array of references to this item IDs respecting the limit above.
If you need more but also maybe more metadata around the relationship a separate collection could give more meaning to it.
What do you think could work?