MongoDB - Large collections of documents

2

I'm developing a site where users can vote for or against places they know. To do this I could create a collection called "votes" relating the location to the user and whether it was for or against, the problem is that this can generate a huge collection of documents, another solution would be for the user document to have an array with your votes so I would separate the collection of votes in the users. What is the best approach to this performance issue?

    
asked by anonymous 08.01.2015 / 13:11

1 answer

2

Particularly, I think the best solution would be to "denormalize".

Leave two fields in the site document (one with the number of positive votes, and the other with negative ones) and another collection of votes, summarizing location + vote + person.

In this way, if you need to list the locations, you already have the information of votes by location (without having to add other collections), and have the information itself in the collection of votes, in case you need to search for specifics per person. >     

29.01.2015 / 19:12