There are 2 approach to handle relationship

  1. References (Normalization)

  2. Embedded document (Denormalization)

  3. Hybrid Approach

  4. Using references :

let author = {
	name : "Mosh"
}

let course = {
	author : 'id';
	
	// author with multiple entities: 
	authors : [ 'id1', 'id2']
	...
	}

Even tho we are referencing the id of author here,  there is no relationship | or association between these 2 documents in database. eg: we can set an invalid id for a course.

Mongo DB does not care about this

  1. Using embedded document
let course = {
	author : {
		name: "mosh"
		},
		 ...
		 
		 }
  1. Hybrid approach
let author = {
	name : 'mosh',
	// other properties 
}

let course = {
	author: {
		id : 'ref',
		name: 'Mosh'
	}
} 

Which one we should pick depends on, query performance vs consistency.

  1. Normalization → consistency