Recently I\'m exploring NoSQL Databases. I need an advice about how to store data in the most optimal and efficient way for a given problem. I\'m targeting MongoDB, now. However
I would suggest storing votes as a list of story _id
s in each user. That way you can find out what stories a user has voted for just by looking at the list. To get the users who have voted for a story you can do something like:
db.users.find({stories: story_id})
where story_id
is the _id
of the story in question. If you create an index on the stories
field both of those queries will be fast.