In SQL for the integrity of data, following four conditions must be met:
Atomicity
Atomicity makes the data consistent. It is that either the transaction should be completed or it should not start at all that is it should not hang in the middle.
Consistency
Consistency is that when a transaction is taking place on a database item, then access to it should not be allowed to other users during that transaction.
Isolation
Isolation is that multiple transactions taking place on a single database item should not affect each other.
Durability
Durability is that if through one transaction a database item is updated, added or deleted, it is accessible to everyone. After a transaction completes successfully, it makes that system consistent and if the system crashes then the change in database item is not lost.
If the above listed four conditions are met only then there is data integrity.
In SQL data consistency is that whenever a transaction is performed, it sees a consistent database. During the transaction, if the database is not consistent, then there are two reasons for it, which are as follows:
Database Failure
Hardware failure
Software failure
Multiple Accesses
Data integrity and data consistency are a must for each other, as data integrity ensures data consistency and vice versa.
Atomicity
Atomicity makes the data consistent. It is that either the transaction should be completed or it should not start at all that is it should not hang in the middle.
Consistency
Consistency is that when a transaction is taking place on a database item, then access to it should not be allowed to other users during that transaction.
Isolation
Isolation is that multiple transactions taking place on a single database item should not affect each other.
Durability
Durability is that if through one transaction a database item is updated, added or deleted, it is accessible to everyone. After a transaction completes successfully, it makes that system consistent and if the system crashes then the change in database item is not lost.
If the above listed four conditions are met only then there is data integrity.
In SQL data consistency is that whenever a transaction is performed, it sees a consistent database. During the transaction, if the database is not consistent, then there are two reasons for it, which are as follows:
Database Failure
Hardware failure
Software failure
Multiple Accesses
Data integrity and data consistency are a must for each other, as data integrity ensures data consistency and vice versa.