Data Modeling medium
What is a 'Soft Delete' and why is it used?
- A A low-level system process that temporarily purges a record from the localized node cache while maintaining a permanent copy on the physical disk.
- B An optimization strategy that removes the raw data from a row but preserves the primary key index so that the ID can be safely reused for future inserts.
- C The pattern of marking a row with a boolean flag (e.g., `is_deleted=true`) to hide it from the application while physically preserving the record for auditing.
- D A destructive storage operation that immediately zeroes out the targeted block on the disk to ensure that sensitive information cannot be recovered.
Answer: C. The pattern of marking a row with a boolean flag (e.g., `is_deleted=true`) to hide it from the application while physically preserving the record for auditing.
Soft deletes are essential for maintaining historical audit trails and preventing the 'orphaning' of records that might still be referenced by background processes. By simply flagging a row as inactive, you enable features like 'Undo' and preserve accidental deletion recovery. However, this comes at the cost of query complexity (you must always filter for active rows) and potential index bloat over time as the physical table continues to grow.
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)?