Database Consistency

Database Consistency States That Only Valid Data Be Input into the Database

Double exposure businessman hand working on laptop with chart finance and technology
Database consistency is the second step in the ACID model. Busakorn Pongparnit/Getty Images

Database Consistency states that only valid data will be written to the database. If a transaction is executed that violates the database's consistency rules, the entire transaction will be rolled back and the database will be restored to its original state. On the other hand, if a transaction successfully executes, it will take the database from one state that is consistent with the rules to another state that is also consistent with the rules.

Database consistency doesn't mean that the transaction is correct, only that the transaction didn't break the rules defined by the program. Database consistency is important because it regulates the data that is coming in and rejects the data that doesn't fit into the rules. 

Example of Consistency Rules at Work

For example, a column in a database may only have the values for a coin flip as "heads" or "tails." If a user were to attempt to put in "sideways," consistency rules for the database would not allow it.

You may have experience with consistency rules about leaving a field in web page form empty. When a person is filling out a form online and forgets to fill in one of the required spaces, a NULL value goes to the database, causing the form to be rejected until the blank space has something in it. 

Consistency is the second stage of the ACID model (Atomicity, Consistency, Isolation, Durability), which is a set of guidelines for ensuring the accuracy of database transactions.

Format
mla apa chicago
Your Citation
Chapple, Mike. "Database Consistency." ThoughtCo, Aug. 15, 2017, thoughtco.com/database-consistency-definition-1019249. Chapple, Mike. (2017, August 15). Database Consistency. Retrieved from https://www.thoughtco.com/database-consistency-definition-1019249 Chapple, Mike. "Database Consistency." ThoughtCo. https://www.thoughtco.com/database-consistency-definition-1019249 (accessed December 14, 2017).