How would you combine soft deletes with email uniqueness?
A users table has a UNIQUE constraint on its email column. The team now wants to introduce soft deletes: instead of removing an account's row, the database keeps it and records the deletion time in deleted_at. After an account is deleted, the person should be able to register again with the same email address. The old account must remain available for auditing. How would you change the constraints? What happens if someone tries to restore the old account or if two registration attempts happen simultaneously?
ExplainDDL, keys, and normalizationSeniorBackendData EngineerQA