I come from MySQL background and I am trying to learn MongoDB. I have product documents, and each product document has a category. Right now I am letting the user choose the category manually but what I want is to show a drop down menu with all the categories that have been defined by me.
In MySQL I would create a categories table and get all of those and show them to the user. How would I store those categories in MongoDB?
In this case I would still have a categories collection and have an ObjectId pointer to the other collection, just so that you can have a single master list of all the categories but still also have the embedded category in the document so that you can perform searches based on that. You won’t have full relationship but you can keep track of the categories avail in a single place.
IMO, The philosophy of mongo does not mean to get rid of all relations but just to have them where it makes sense.