🎁 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

B-Tree Index
The default index type in most databases that organizes data in a balanced tree structure for efficient searching, sorting, and range queries.
Database Proxy
A middleware server that sits between applications and databases, providing connection pooling, load balancing, and query routing.
Database Backup
The process of creating copies of database data to protect against data loss from failures, corruption, or human error.
JOIN
An SQL operation that combines rows from two or more tables based on a related column between them.
Index
A data structure that improves the speed of data retrieval operations on database tables at the cost of additional storage.
Prepared Statement
A pre-compiled SQL template that uses parameters instead of literal values, preventing SQL injection and improving performance.
View All Databases Terms →