0

I'm not sure whether the auto generated id (object_id) of mongodb is unique across all the document or not. I've a dilemma about referencing.

Says I have a system which multiple users can create their own products and categories. So I will have product collection and category collection.

To get a category of a product, should I get the category by using user id and product id or product id alone is enough? since I will first get the product id using user id before I can find the category of that particular product.

Community
  • 1
  • 1
Nichole A. Miler
  • 1,281
  • 2
  • 11
  • 21
  • have a check at : http://stackoverflow.com/questions/4677237/possibility-of-duplicate-mongo-objectids-being-generated-in-two-different-colle – Louis F. Jan 04 '16 at 21:05
  • @LouisF. so I'm over worried? I don't have to put user_id in every collection to do double query am I right? – Nichole A. Miler Jan 05 '16 at 02:28
  • May I invite you to read this comprehensive documentation about how to model datas in MongoDB ? Depending on the nature of the relationship between product and categories, you will end up with different models. The link : ttps://docs.mongodb.org/manual/core/data-modeling-introduction/ – Louis F. Jan 05 '16 at 08:01

0 Answers0