This document provides an overview of MongoDB including what it is, how to use it, best practices for database design, building scalable applications, and new transaction capabilities in MongoDB 4.0. It defines MongoDB as a non-relational database that uses documents with dynamic schemas, nested objects and arrays. It covers CRUD operations, queries, indexing, aggregation, denormalization techniques, replica sets, sharding, choosing the right shard key, and how to implement transactions in MongoDB 4.0 including starting a session, transaction, and committing or rolling back changes.
25. Thought Transformation
25
EFFECTIVE DB DESIGN
25
Degree of
association
Relational
or not?
Understand your
data & think
differently
Is NoSQL right
for your use
case?
How deeply
relational is your
data?
01 02 03 To what extent
each document can
be denormalized?
How many relations
exist per
document?
44. Choosing a Shard Key
44
BUILDING SCALABLE APPS
44
Shard Key determines how your data is divided
Create a Shard Key that targets a single shard
High degree of randomness
Easily divisible shards
45. When to Shard
45
BUILDING SCALABLE APPS
45
Plan ahead
Choose a shard key wisely - it cannot be changed
You cannot unshard a sharded collection