Engineering Decisions · Junior · Question 8 of 12

Moderators delete comments, and sometimes must restore one within 30 days. Regular queries should stay simple. How do you implement deletion?

Show the answer

Correct answer: Set deleted_at, and purge old rows on a schedule

Explanation

A deleted_at column makes restoring a one-line update, and a scheduled job can purge rows after 30 days, as long as queries filter out deleted rows. Restoring from a backup fits disaster recovery, but it's slow and clumsy for one comment. An archive table fits data that is rarely restored and keeps the main table clean, at the cost of extra code for each restore.

Further reading

Problem with a question

Engineering Decisions · Junior · question 8

Test yourself

Take the Engineering Decisions · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz