Data Modeling medium
You have `Orders` and `Customers`. In a Document DB, you embed `Customer` info into `Order`. What happens if the Customer updates their phone number?
- A The database hardware automatically detects the relationship and performs an atomic background update across all physically distributed shards.
- B The update operation is rejected by the database's strict synchronization lock until the application explicitly resolves the potential data conflict.
- C You must manually identify and update every individual 'Order' document that contains the old information, risking data inconsistencies if any step fails.
- D Document-oriented databases are designed to be append-only and do not support the direct modification of existing record attributes once they are stored.
Answer: C. You must manually identify and update every individual 'Order' document that contains the old information, risking data inconsistencies if any step fails.
This is the 'Denormalization Penalty'. By embedding data for faster reads, you trade off write simplicity. In a relational database, you update exactly one row in the `Customers` table, and all joined `Orders` reflect the change immediately. In a document store, you either accept stale data for historical records (which might be intended) or you must manage a complex 'cascading' update process at the application level.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When modeling a Distributed Transaction using the Saga Pattern (Choreography or Orchestration), what type of consistency do you achieve?
- Which practice prevents SQL Injection attacks?
- What is 'Bi-Temporal' data modeling (e.g., in SQL:2011 standard)?
- Adding an Index to a database column generally improves Read performance. What is the negative trade-off?
- Log Systems Merge (LSM) Trees (used in RocksDB, Cassandra) optimize for fast writes. What is their primary downside regarding Disk I/O?
- What is the primary objective of normalizing a relational database schema (e.g., to 3NF)?