Week 6 L1 Flashcards
What is embedding and referencing ?
MongoDB does not support FK referencing of PK, there is no join operator.
Embedded object is implicitly joined
Referencing is controlled by application
What is one collection embedding ?
when embedded object not used independently of its parent object . Generally known as data aggregation.
Advantages of one collection embedding?
Provides performance advantage
Associated data is held in one document
data access by single command
What is single association embedding?
employee works on exactly one machine. Embedding one document in another. Embedded object no longer independent .
Advantages of Single Association embedding
everything in one place. makes updates very efficient
What is multiple association embedding
Multiple child objects embedded in one parent object. makes it difficult to insert child objects independent of parent.
When does multiple association embedding work well ?
Works well when the zero one or many relationships are few .
How to access document embedded fields?
Use dot notation
What is two collections referencing ?
Two collections used independently. requires two steps or join to retrieve related data from collections
application must control the referencing between documents
Advantages of two collections referencing
More flexible than embedded
What is single association referencing ?
Closest to the relational design solution
Employee works on exactly one machine
Allows objects to be independent
How do you reference?
update collection by add id reference into other object
How to reference across collection?
Use a loop with a cursor
What are alternatives to he join method ?
$lookup
What is multiple association referencing
0 one or many relationships.
Two collections with an array of references