What is data integrity ? -It is important that data adhere to a predefined set of rules, as determined by database administrator or application developer and also the obvious and natural validation. For example no two customers of the bank may have same account number or a value for gender column can be one from Male, Female and Rather Not Say.
So, in short, "data integrity" ensures the quality of the data in the database and it's enforcement prevents entry of any invalid data into the database tables.
Types of Data Integrity -Two important steps in designing a table from "data integrity" point of view is, first identifying the set of valid values for certain columns and secondly, decide how to ensure that only valid values make their way to the column(s). This entails the need for categorizing the "data integrity" -
- Entity Integrity
- Referential Integrity
- Domain Integrity
- User-Defined (custom) integrity
How to enforce Data Integrity ? -
- Declarative Constraints on the columns of the table.
- Database Triggers
- Use of appropriate datatypes and precisions (width of the column)
- use of views containing "with check option" clause
Here is a link to an interesting quiz, some food for thoughts : Click Here