7. Data modeling
• Embedding
– you have “contains” relationships between
entities
– you have one-to-many relationships where
the “many” objects always appear with or are
viewed in the context of their parent
documents
8. Data modeling
• Referencing
– when embedding would result in duplication of
data but would not provide sufficient read
performance advantages to outweigh the
implications of the duplication
– to represent more complex many-to-many
relationships
– to model large hierarchical data sets
13. Sharding
• Sharding automatically balances data and
load across machines. Sharding provides
additional write capacity by distributing
the write load over a number of mongod
instances.
Inserite l’eventuale vostro logo in basso a destra
Slide da mostrare prima di iniziare la sessione – non rimuovere!
Embedding provides the following benefits: - generally better performance for read operations. - the ability to request and retrieve related data in a single database operation. Embedding related data in documents, can lead to situations where documents grow after creation. Document growth can impact write performance and lead to data fragmentation. MongoDB only provides atomic operations on the level of a single document. As a result needs for atomic operations influence decisions to use embedded or referenced relationships when modeling data for MongoDB. Embed fields that need to be modified together atomically in the same document.