Interview practice question
Duplicate usernames despite a check
Backend Engineering · Relational Databases · Beginner
Your signup code checks if a username exists before inserting, but duplicates still appear. Why, and how do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Check-then-insert race condition.
- Two requests pass check simultaneously.
- Add UNIQUE constraint.
- Handle constraint violation error.
- Return 409 to client.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.