🎁 New User? Get 20% off your first purchase with code NEWUSER20 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

Elastic Search
A distributed search and analytics engine built on Apache Lucene, optimized for full-text search and log analysis.
Query Optimization
The process of improving database query performance through indexing, query rewriting, and schema design techniques.
Deadlock
A situation where two or more transactions permanently block each other by each holding locks that the other needs.
Graph Database
A database that uses graph structures with nodes, edges, and properties to store and query highly connected data.
SQL
Structured Query Language — the standard language for managing and querying data in relational databases.
Materialized View
A database object that stores the precomputed result of a query, offering faster reads at the cost of periodic refresh.
View All Databases Terms →