At the job I’ve been in for the past year, we frequently work with a VIN (Vehicle Identification Number). Each car has a 17 character code that uniquely identifies it. There is a pattern to the VIN, where the characters in certain positions have a specific meaning (Although North America and Europe use different conventions). The first three characters designate the manufacturer and the country of origin, the 10th character is a code for the model year, etc.
The ninth character is a check sum, so we can use that to validate the VIN, as a check to make sure a VIN was input correctly. Of course, it can’t be 100% (You can always make a mistake that still passes the validation). The characters in each position have a different weight, so those values are used to calculate the check sum (Similar to the Luhn algorithm that’s used to validate a credit card number).
Wikipedia has this article to explain how the check sum is generated and validated.
I’ve also posted this script on that creates a function that will validate a VIN. The script is written for Postgres, but could be adapted to other database systems. Everything in the script was taken from the Wikipedia article (Just as a disclaimer, this script wasn’t something I did at work, just something I put together to understand the check sum process).