'How would YouTube store data of who liked which videos?
If Youtube uses MongoDB as their database, then how would they store the who liked which videos information?
Option 1:
Store it in the Videos
collection with a field that holds a list of subdocuments containing the user id and weather they liked it or disliked it.
Option 2:
Store it in the Users
collection with a field that holds a list of subdocuments containing the video id and weather they liked it or disliked it.
Option 3:
Store this many-to-many relation in its own collection.
Questions.
- Would the document size in Options 1 be at risk of exceeding the 16 MB limit?
- Would the document size in Options 2 be at risk of exceeding the 16 MB limit?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|