I am building an e-learning app, and showing student activities as a timeline, should I embed them in the user
collection, or create a separate collection with an userId
.
Constraints:
- One to many relationship.
- User activities are detailed and numerous
- For 90% of the time, we only need to see one user at an time, the other case is where a supervisor(teacher) needs to see an summary of the activities of users(maybe another collection?)
- I haven't thought of the use case of searching for activities and finding students, maybe I'll have a use for this later on? (eg. see who finished some particular activity first? But that changes the relationship to be Many to many and is a completely different question)
I have found different schemas for the related problem in these two questions:
- MongoDB schema design -- Choose two collection approach or embedded document recommends to
try and embed as much as possible
- MongoDB schema for storing user location history reminds
don't bloat a collection, because querying the elements deep below might be hard, especially if you're going to use lists