For years I have worked with relational databases within a LAMP stack, I am now trying to move to a MERN stack and as a result trying to get my head around mongodb and it's flat(?) design.
Previously if I wanted a user
to be able to store images
I would have had 1:n relationship with the table rows looking similar to this,
user
0001 test1@user.com 2018-05-05
0002 test2@user.com 2018-05-05
0003 test3@user.com 2018-05-05
images
001 filename1.jpg 0001
002 filename2.jpg 0001
003 filename3.jpg 0001
004 filename4.jpg 0002
005 filename5.jpg 0002
006 filename6.jpg 0003
With the last number in the images table being the user_id. Now I have read about mongodb but still follow how I would replicate this, would I embed an images collection within my user collection, like a nested object,or would I have an images collection that somehow references the users id?