Data integrity
Data integrity ensures that the data within the database is reliable and adheres to business rules. Data integrity falls into the following categories:
- Domain integrity: This ensures that the values of the specified columns are legal, which means domain integrity ensures that the value meets a specified format and value criteria. You can enforce domain integrity by restricting the type of data stored within columns (through data types), the format (through
CHECKconstraints and rules), or the range of possible values (throughFOREIGN KEYconstraints,CHECKconstraints,DEFAULTdefinitions,NOT NULLdefinitions, and rules). - Entity integrity: This ensures that every row in the table is uniquely identified by requiring a unique value in one or more key columns of the table. You can enforce entity integrity through indexes,
UNIQUE KEYconstraints,PRIMARY KEYconstraints, orIDENTITYproperties. - Referential integrity: This ensures that the data is consistent between related tables. You can enforce referential integrity through
PRIMARY KEYconstraints andFOREIGN KEYconstraints. - User-defined integrity: This ensures that the values stored in the database remain consistent with established business policies. You can maintain user-defined integrity through business rules and enforce user-integrity through stored procedures and triggers.