Friday, August 28, 2015

Don't store the last four digits of a credit card number as an int.

What if there is a leading zero? Or two? You'll have to do wacky stuff to compensate, right? This data point should be a nchar(4) at MSSQL and a string at C#. (This touches on the difference between nchar, char, varchar, and nvarchar. The items with the leading n can store Unicode characters (and thus they take up much more memory) while the others cannot. The items with var in the name are of variable length can be up to their specified length in length and can also be less while the nchar and char settings are going to use storage space for all x of their slots even if you use less than x.)

No comments:

Post a Comment