I was wandering what keep MongoDB faster. Having a few parent documents with big arrays of embedded documents inside of them or having a lot of parent documents with few embedded documents inside.
This question only regards querying speed. I'm not concerned with the amount of repeated information, unless you tell me that it influences the search speed. (I don't know if MongoDb automatically indexes Id's)
Example:
Having the following Entities with only an Id field each one:
- Class (8 different classes )
- Student ( 100 different students )
In order to associate students with classes, would I be taking most advantage of MongoDB's speed if I:
- Stored all Students in arrays, inside the classes they attend
- Inside each student, I kept an array with the classes they attend.
This example is just an example. A real sittuation would involve thousands of documents.