Facebook Pixel

How do I handle stale data with denormalization?

Either update on change (when the user's name changes, update all their posts; expensive but consistent) or accept staleness (the name on old posts stays as it was; cheaper, fine for many cases like chat messages). Decide based on the feature's needs.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Denormalization vs Normalization in MongoDB

Normalization stores each fact once and references other collections (join on read). Denormalization copies data where you need it (no join). Normalize for data that changes often; denormalize for high-traffic reads of rarely-changing data.

When data rarely changes (author name on a message), reads are high-traffic and slow with joins, you need fast reads for UX, and the duplicated data is small. MongoDB rewards denormalization for high-traffic reads.

When data changes often (user profile, prices), you need consistency (one copy of each fact), reads are not high-traffic, or the referenced document is large. Use refs and populate.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.