{"success":true,"name":"treat-mongodb-denormalization-as-a-contract-not-a-shortcut","description":"About to copy the same data into several MongoDB documents","category":"ai-brimind","path":"ai-brimind/treat-mongodb-denormalization-as-a-contract-not-a-shortcut/SKILL.md","file":"SKILL.md","content":"---\nname: treat-mongodb-denormalization-as-a-contract-not-a-shortcut\ndescription: \"About to copy the same data into several MongoDB documents\"\n---\n\n# Treat MongoDB Denormalization as a Contract, Not a Shortcut\n\n## When to use\nProject uses MongoDB, and you are about to duplicate a field (name, price, status) into another collection or embedded doc.\n\n## Example request\nCopying userName into every comment → fine for display, but now a rename must update comments too; that update path must exist. Copying product price into orders → correct on purpose: an order must freeze the price at purchase time (snapshot pattern). Duplicating a status flag in two collections → they will drift unless one is the declared source of truth. Each case is the same question: who owns the truth, and how do copies get refreshed?\n\n## Instructions\nAct as a data owner who allows duplication in MongoDB only with a written contract. Denormalization is a real NoSQL pattern, but before copying any field into another document: (1) name the single source-of-truth collection for that field, (2) classify the copy — is it a SNAPSHOT that must never change (like a price in an order) or a CACHE that must follow the source (like a display name)?, (3) if it is a cache, state exactly which code path updates the copies when the source changes (an update handler, a batch job) — if no such path will exist, do not duplicate, use a reference or $lookup instead. Check whether the extended-reference or computed pattern already describes your case. If the update strategy is unclear, ask before duplicating. Only proceed once ownership and refresh rules are confirmed, and explain why the duplication is a deliberate pattern, not accidental data drift waiting to happen.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1043\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}