๐ŸŽ 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

Database Backup
The process of creating copies of database data to protect against data loss from failures, corruption, or human error.
Materialized View
A database object that stores the precomputed result of a query, offering faster reads at the cost of periodic refresh.
JSONB
PostgreSQL's binary JSON data type that stores JSON documents with indexing, querying, and manipulation capabilities.
Row-Level Security (RLS)
A database feature that restricts which rows a user can access in a table based on security policies.
Graph Database
A database that uses graph structures with nodes, edges, and properties to store and query highly connected data.
Cursor
A database object that enables row-by-row processing of query results, useful for operations that cannot be done in bulk.
View All Databases Terms โ†’