๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Databases Intermediate

What is Soft Delete?

A pattern where records are marked as deleted with a flag or timestamp rather than being physically removed from the database.

Soft delete adds a deleted_at timestamp or is_deleted boolean to tables. Queries filter out deleted records: WHERE deleted_at IS NULL. This preserves data for auditing, undo functionality, and referential integrity.

Trade-offs include increased storage, more complex queries (must always filter), unique constraint challenges, and GDPR compliance concerns (soft-deleted data still exists). Alternatives include audit tables (copy before delete) and event sourcing.

Related Terms

Write-Ahead Log (WAL)
A technique where changes are first written to a log before being applied to the database, ensuring crash recovery and data integrity.
Connection String
A formatted string containing all parameters needed to establish a connection to a database server.
Stored Procedure
A precompiled collection of SQL statements stored in the database that can be executed as a single unit.
Vacuum
A PostgreSQL maintenance operation that reclaims storage from dead tuples and updates statistics for the query planner.
Deadlock
A situation where two or more transactions permanently block each other by each holding locks that the other needs.
MVCC (Multi-Version Concurrency Control)
A technique where the database maintains multiple versions of data to allow concurrent reads and writes without locking.
View All Databases Terms โ†’