I just want to get some advice on the best way to set up simple references:
I am trying to decide whether I should:
-
Create 2x collections and have the documents from
col1
reference documents incol2
using a$lookup
or rather -
create 1x collection and embed the reference data within the main document?
Note, the relationship is a one to many relationships. As an example, collection 1 is a “bank” and collection 2 is “cars”. The bank can finance many cars, but a car can only be referenced to one bank.
The reason for my question is in terms of execution speed. If I have 1x bank document but half a million car documents.
When I run a query, will the query be:
a) faster with and array of embedded documents or
b) $lookup (assuming cars is a collection of its own)?
Appreciate any effort and assistance.