What Does Consistency Mean?
Consistency, in the context of databases, states that data cannot be written that would violate the database’s own rules for valid data. If a certain transaction occurs that attempts to introduce inconsistent data, the entire transaction is rolled back and an error returned to the user.
Techopedia Explains Consistency
A simple rule of consistency may state that the ‘Gender’ column of a database may only have the values ‘Male’ , ‘Female’ or ‘Unknown’. If a user attempts to enter something else, say ‘Hermaphrodite’ then a database consistency rule kicks in and disallows the entry of such a value.
Consistency rules can get quite elaborate, for example a bank account number must follow a specific pattern- it must begin with a ‘C’ for checking account or ‘S’ for savings account, then followed by 14 digits that are picked from the date and time, in the format YYYYMMDDHHMISS.
Database consistency does not only occur at the single-record level. In our bank example above, another consistency rule may state that the ‘Customer Name’ field cannot be empty when creating a customer.
Consistency rules are vitally important while creating databases, as they are the embodiment of the business rules for which the database is being created. They also serve another important function: they make the application developers’ work easier- it is usually much easier to define consistency rules at the database level rather than defining them in the application that connects to the database.