In the quiz for lesson 3 on Modelling Data Relationships, I have trouble understanding the difference between a wrong and a correct answer.
Which of the following are valid ways to represent this one-to-many relationship between the customer and their transactions?
Wrong answer: ‘Then document contains […] an array that holds all their transactions.’
Correct answer: ‘Embed the transactions for each customer as an array of subdocuments in the corresponding customer document’.
As an explanation for why the first is wrong, it says that You don't want to create an unbounded array in your schema..
As an explanation for why the second is correct, it says that f your application frequently retrieves the transactions data with the customer's information, you should consider embedding so that your application doesn't need to issue multiple queries to resolve the references., with an additional warning about the 16MB document size limit.
I don’t get it. Both are unbound arrays? As more transactions are recorded, the array will grow?
which course is this one? provide us a link to see what those questions have in mind.
But, basically, you would embed most used relations and separate others into corresponding collections. for example, transactions from the last 7 to 30 days are fit to be (also) embedded if their numbers are not excessive. or top 10 reviews of a product is also fit to embed. on the other hand, while you can embed today’s weather data with hourly intervals, ever-growing 15-minute weather data is not suitable to embed. you may embed a patient’s weekly heart statistics (as long as it is small enough), but not hourly readings.
so, the contexts of those questions are important.
The question asks for valid ways to connect customers with their transactions.
I can’t really see the difference between ‘customer document contains an array that holds all their transactions’ and ‘embed the transactions as an array in the customer document’.
Thanks for the link. Please include this link in your first question post so others won’t need to scroll down to find it, and also state it is the 2nd question.
I also agree there is a vagueness in the answers. besides having an array of objects, both answers also refer to the same limitation with two terms: unbounded array and document size limit of 16MB. I am guessing they had something else in mind but this slipped into the result.
@Kushagra_Kesav, I would appreciate it if you tag someone from the “learn” team.