Where to start?

Hi, im new in DB with experience in programming and i’m trying to develop a aplicaction where the user has a inventory with cards, this cards the user can use it to fight and sell it in a global market, so my idea was to create a poll where all the cards with his especs are and then when a user achieve to get one copy all the info of the card put it in the user document, so now the card have a special id (not _id) and it belongs to the user, but in the card in the poll continue the same.
Any tutorial or documentation that help me with this especific problem.

Hi @Sergio_Rodrigo_Ortiz_Avina,

Welcome to mongodb community.

So a card is drawed by a user from the “main deck” and than it should belong yo that user and never be drawen again?

In that case I believe you should have a main cards collection and when a user draw it , it moves from that collection to a cards_users collection where you can place a user_id and index it in that collection.

If that needs to be all or nothing operations you may consider transactions.

How many cards can a user draw? If the number is unlimited or high i wouldn’t embed it in the users collection (may create unbounded array issue).

I suggest to read

MongoDB Schema Design Best Practices | MongoDB.


Thanks to answer, and yes the read help me to understand better.
About your answers the user has a inventory there are all the cards he has. From there the user can create a “team” of 3 cards (they need to be in the inventory) and that team is the one the user use to fight.

And my main concern is about the cards because i want that this are all predefined, so when the user obtain one i only call that object and now become part of the user inventory, so now that cards have a unique key in the user inventory, this because is the user want to sell this object in a global market do it with this id.
To finally the user had a exact copy of the card in his inventory that can modify but this can’t modify the originally card that is in the “cards poll”

Ok so duplicate the cards from the main pool to user inventory.

Now weather this inventory is embedded or have another collection with an indexed user_id depands on the size of this amount per user. If a user can have thousands of cards it won’t work embedded. But if it is 10s then it might be ok.

Anyway the top 3 should probably be embedded anyway.

Hope this helps