Database constraints: when (and why) you should use them

You can't expect application code to always write clean data into your database. Understanding when to use constraints or concurrency control tools will help you build scalable systems.