Hi,
I’ve worked a lot with SQL and now I’m trying to learn how to use MongoDB.
I decided to use the game Stardew Valley for this, because that’s information I have. Now the first stumbling block I run into is how to store my data in collections to be able to look up the things I want. I have different types of data:
-
trees & crops: season, buy price, fruit sell price
-
fish: season, weather, location, hours
-
recipes: ingredients (will come from the previous two), sell price, buffs
-
machines: inputs (will come from the first two), outputs, sell price
-
NPCs: mainly which NPC likes which item out of all of the previous
Just to show this is about very different data. In SQL, each of these would be a separate table, there’d be extra reference tables (like seasons), the NPC liked items would probably end up being a union of data grabbed from all the previous.
In MongoDB, I’ve read collections being referred to as Mongo’s equivalent to tables, but I also get the impression it is not generally the intention to try and combine them, or grab information from multiple ones. It’s possible but seems like extra hassle and kinda not meant to be done (I may have found wrong answers, I don’t know). So say that, for example, I wanted to look up all of the resources I would need to fulfill the wants of one NPC – that means, 1) apples (method:raw), 2) bass (fish) and wheat to make the recipe of breaded fish (method: kitchen), 3) strawberry and milk to make strawberry ice cream (method: ice cream machine) etc. In other words, I basically want to be able to grab data from every last one of these categories and combine them, and that is the most frequent thing I want to do.
-
Do I put all of these different categories in the same collection?
-
Do I put them in different collections, in which case, a pointer to useful documentation of how to get the results I want would be very appreciated.
-
Is this too complicated for MongoDB alone/ Would I need to figure this out in my actual application somehow? I am told MongoDB can do everything SQL can and is basically much better at it, so I would expect this to be possible…?
The idea behind all this is basically, if you learn how to do the most difficult thing, then everything simpler will be a piece of cake later. Please keep in mind, if possible, that right now I’m doing this with a silly game with very limited data but I would like to know the best or most recommended ways of thinking about this so I can apply this to important stuff later.
Thank you very much for your input.