Chapter 8. Data Integrity

This chapter discusses the ways data can be validated before it is entered into the database. Validation is particularly important when many people are entering data and sharing the same database. Validation also ensures that the data meets a certain level of consistency.

In a relational database, referential integrity is one of the main techniques of data validation. It protects columns that contain codes. For example, a column for gender can only contain the codes M and F. Referential integrity can enforce that rule.

A check constraint is another type of validation. It can check that some statement is true; for example, “Price is less than $100.00.” There is always validation on the primary key of a table to preserve ...

Get SQL Fundamentals, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.