开发者

MongoDB :: Database Design

I'm using MongoDB. I have Users and I have Things. A user can follow or like those things and he can also follow another user. Where should I store the list of likes and follows? In SQL that was a JOIN call with a table of following / type / followed, but in Mongo, well... I just don't know.

Options I think of:

  1. A collection with following / type / followed, each has a DBref

  2. Storing the data twice, once in the users collection and once in the things collection. The maintainability of this looks bad and so does 开发者_开发百科querying.


I would suggest option 1 since you might need to do some computation. Map reduce works only on one collection for now. It's also easier to provide stats. I don't really use DBref but this approach has owrked pretty well so far for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜