This document discusses 5 key data modeling patterns for document databases: 1) One-to-many using embedded documents, 2) Many-to-many using references or embedded documents, 3) Trees using parent and child references, 4) Trees using materialized paths, and 5) Entity aggregation for polymorphic documents. It provides examples of each pattern and considerations for implementing them. The document also covers anti-patterns to avoid, such as large arrays and over-normalizing data.
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
Modeling with Document Database: 5 Key Patterns
1. Modeling with Document
Databases:
5 Key Patterns
Dan Sullivan, Principal
DS Applied Technologies
Enterprise Data World 2015
Washington, D.C.
April 1, 2015
2. My Background
Data Architect / Engineer
NoSQL and relational data
modeler
Big data
Analytics, machine learning
and text mining
Cloud computing
Computational Biologist
Author
No SQL for Mere Mortals
Contributor to TechTarget
5. Schema-less <> Model-less
Schema-less Document
Databases
No fixed schema
Polymorphic documents
...however, not a Design
Free for All
Queries drives organization
Performance Considerations
Long-term Maintenance
Middle Ground: Data
Model Patterns
Reusable methods for
organizing data
Model is implicit in
document structures
6. Patterns
Commonly used structure and
organization
Abstraction, not implementation
specific
Popularized by “Gang of Four”
Applied to Relational Databases
by David C. Hay
Applies to NoSQL
7. Patterns
Pattern 1: One-to-Many
Pattern 2: Many-to-Many
Pattern 3: Trees with References
Pattern 4: Trees with Materialized Views
Pattern 5: Entity Aggregation
9. One-to-Many Considerations
Query attributes in
embedded documents?
Support for indexing
embedded documents?
Potential for arbitrary
growth after record
created?
Need for atomic writes?
10. Patterns
Pattern 1: One-to-Many
Pattern 2: Many-to-Many
Pattern 3: Trees with References
Pattern 4: Trees with Materialized Views
Pattern 5: Entity Aggregation
17. Tree Considerations
Children reference allow for
top-down navigation
Parent references allow for-
bottom up navigation
Combination allow for
bottom-up and top-down
navigation
Avoid large arrays
Consider need for point in
time data
18. Patterns
Pattern 1: One-to-Many
Pattern 2: Many-to-Many
Pattern 3: Trees with References
Pattern 4: Trees with Materialized Views
Pattern 5: Entity Aggregation
19. Pattern 4: Trees with Materialized
Paths
Full path from document
to root is represented in
document
Implement with arrays or
string
Especially useful in
hierarchical queries, i.e. a
type and all its subtypes
21. Materialized Paths Considerations
Support for multi-key
indexing of arrays
Use of regular expressions
for pattern matching when
string is used
Ability to utilize indexes
when string representation
22. Patterns
Pattern 1: One-to-Many
Pattern 2: Many-to-Many
Pattern 3: Trees with References
Pattern 4: Trees with Materialized Views
Pattern 5: Entity Aggregation
23. Pattern 5: Entity Aggregation
Entities with sub-types
Relational models use
multiple tables
Document models use
varying embedded
documents
Source of
polymorphism
27. Anti-Patterns
Large arrays
Significant growth in
document size
Fetching more data than
needed
Fear of data duplication
Thinking SQL, using
NoSQL
Normalizing without need
28. Closing Remarks
Consider, is it worth it to
loose:
SQL
Multi-statement transactions
Triggers
Let queries drive model
Consider full life-cycle
Exploit polymorphism