codejump

Soft Deletes & Multitenancy

Preview — 3 of 10 questions

What is the soft delete pattern and what column is typically used to implement it?

AAdding a deleted_at TIMESTAMPTZ column that is NULL for active records and set to the deletion timestamp for deleted ones
BMoving deleted rows to a separate archive table immediately on delete
CMarking rows with status = 'deleted' and using a CHECK constraint to prevent further updates
DUsing cascading deletes with ON DELETE SET NULL on all child foreign keys

Which index is most efficient for a table with soft deletes, where most queries filter on deleted_at IS NULL?

AA standard B-tree index on deleted_at
BA GIN index on deleted_at
CA partial index: CREATE INDEX ON users (email) WHERE deleted_at IS NULL
DNo index is needed since NULL comparisons are inherently fast

In single-table inheritance (STI), how are multiple entity types (e.g., Employee, Manager, Contractor) stored?

AEach type has its own table with no shared columns
BAll types are stored in one table with a discriminator column (e.g., type) and type-specific columns that are NULL for rows of other types
CA junction table maps each entity row to its attribute set
DEach type inherits columns from a parent table using PostgreSQL table inheritance syntax

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.