Assume that you have a “users” and “logs” collections. A user can have many logs. As you can imagine, this is a mutable operation and you cannot guarantee how many logs a user could potentially have. It may be 1 or a million! In such cases it is ideal to store parent collection’s reference in child collection. So in this case the log contains user reference in it. See example below.
#go #mongodb #golang