MongoDB and composite primary keys

前端 未结 4 1619
温柔的废话
温柔的废话 2020-12-07 21:55

I\'m trying to determine the best way to deal with a composite primary key in a mongo db. The main key for interacting with the data in this system is made up of 2 uuids. Th

4条回答
  •  醉梦人生
    2020-12-07 22:34

    I would've gone with option 2. You can still make an index that handles both the UUID fields, and performance should be the same as a compound primary key, except it'll be much easier to work with.

    Also, in my experience, I've never regretted giving something a unique ID, even if it wasn't strictly required. Perhaps that's an unpopular opinion though.

提交回复
热议问题