04 Chapter Pattern in Mongodb3
04 Chapter Pattern in Mongodb3
BUCKET PATTERN
1
23/10/2022
Bucket Pattern
2
23/10/2022
3
23/10/2022
4
23/10/2022
5
23/10/2022
Bucket Pattern
6
23/10/2022
Summary
˗ Alternative to fully
embedding or fully linking a
1-to-Many relationship
˗ Advanced pattern that
requires a good understand
of the workload
7
23/10/2022
8
23/10/2022
MongoDB Database
9
23/10/2022
10
23/10/2022
Application Lifecycle
11
23/10/2022
Document Lifecycle
12
23/10/2022
Summary
13
23/10/2022
14
23/10/2022
TREE PATTERNS
Tree Patterns
15
23/10/2022
Tree Patterns
Tree Patterns
16
23/10/2022
Tree Patterns
Tree Patterns
17
23/10/2022
Tree Patterns
˗ Who are the ancestors of node X?
˗ Who report to Y?
˗ Find all nodes that are under Z?
˗ Change all categories under N to under P
Tree Patterns
18
23/10/2022
Parent References
{
Name: “Office”,
Parent: “Swag”,
…
}
19
23/10/2022
Parent References
{
Name: “Office”,
Parent: “Swag”,
…
}
Parent References
{
Name: “Office”,
Parent: “Swag”,
…
}
20
23/10/2022
Parent References
˗ Who are the ancestors of node X? (!)
˗ Who report to Y? ()
˗ Find all nodes that are under Z? (!)
˗ Change all categories under N to under P ()
Child References
{
name: “Office”,
Children“:[“Books”,
“Electronics”, “Stickers”]
…
}
21
23/10/2022
Child References
˗ Who are the ancestors of node X? (!)
˗ Who report to Y? (!)
˗ Find all nodes that are under Z? ()
˗ Change all categories under N to under P (!)
Array of Ancestors
{
Name: “Books”,
Parent: [“Swag”, “Office”]
…
}
22
23/10/2022
Array of Ancestors
˗ Who are the ancestors of node X? ()
˗ Who report to Y? ()
˗ Find all nodes that are under Z? ()
˗ Change all categories under N to under P (!)
Array of Ancestors
˗ Who are the ancestors of node X? ()
˗ Who report to Y? ()
˗ Find all nodes that are under Z? (!)
˗ Change all categories under N to under P (!)
23
23/10/2022
Materialized Paths
{
Name: “Books”,
Parent: “.Swag.Office”]
…
}
Materialized Paths
{
Name: “Books”,
Parent: “.Swag.Office”]
…
}
24
23/10/2022
Materialized Paths
˗ Who are the ancestors of node X? ()
˗ Who report to Y? (!)
˗ Find all nodes that are under Z? (!)
˗ Change all categories under N to under P (!)
25
23/10/2022
Tree Patterns
26
23/10/2022
Recap
˗ Documents are good data structure to represent hierarchical
data
˗ Several different patterns to represent trees
˗ Focus on the most common queries and operations to select
the most effective tree pattern
27
23/10/2022
POLYMORPHIC PATTERN
Differences in Objects
28
23/10/2022
Vehicles
29
23/10/2022
Products
Polymorphic Subdocuments
30
23/10/2022
Single View
31
23/10/2022
Polymorphic Patterns
32
23/10/2022
Summary
˗ Basic Pattern
˗ Base of many other Patterns
33
23/10/2022
Other Patterns
˗ Approximation Pattern
˗ Outlier Pattern
Approximation Pattern
34
23/10/2022
Approximation Pattern
Outlier Pattern
35
23/10/2022
Outlier Pattern
36
23/10/2022
Recap
These are some other notable patterns
˗ Approximation Pattern
Avoiding performing an operation too often
˗ Outlier Pattern
Keeping the focus on the most frequent use cases
Summary of Patterns
37
23/10/2022
Summary of Patterns
˗ Pattern are Powerful Transforms for your Schema
˗ Provide a common Language for your Team
˗ More Predictable Methodology
38