Data validation is important in various areas of computer science – database data entry, data warehousing, program input, networking. Any time data is communicated it should be validated. If data is not validated it can cause errors, corrupt data, and crash systems.
Database validation rules
In databasing when entering data into the database it must be verified to ensure it follows the database validation rules – which are laid out in the data dictionary. While the software development validation techniques are relevant they are not the answer to a database validation question. The constraints, data type, size, and examples in the description of the data dictionary specify the validation rules for databasing. If a validation rule is not met then the RDBMS will not allow the record to be stored.
For example, a validation rule for an email address attribute in a customer database may have the validation rules that require it to contain no more than 100 characters, be of a string datatype, and contain one “@” symbol.
Software development
When developing software there are two types of validation techniques to consider.
Range checking
Range checking ensures the data is within the bounds of what is expected. If a rating system allows users to rate something from 1 to 5, but 6 is input that could cause a run-time or logic error.
Type checking
Type checking ensures the data type expected is input and output. If an integer is expected, but a real/float is input that could cause a run-time error.