Data validity and accuracy according to database integrity

database-designterminology

What does it mean that data is valid and accurate according to database integrity?

Best Answer

At the theoretical level, a domain can be represented by a table of values. (At the theoretical level, because the number of values for, say, the domain of non-negative integers is infinite.) Valid values come from that domain.

In a SQL database, you establish valid values using some combination of appropriate data types and constraints. For example, you might declare "employee_id" to be an integer, and restrict the range of integers with a) a foreign key constraint to a table of 'n' integers or b) a check constraint.

Accurate means that, of all the possible valid values, a user has chosen values that correspond to the entity's state or description in the real world. In this sense, user can be either a human or a program.

For example, let's say a book in a library can have any of these dispositions: "checked out", "recently returned" (not yet in the stacks), "in stacks", "being repaired", and "lost". If I check out a book and the database stores it's status as "checked out", then the database is accurate with respect to the disposition of that copy. (At my library, checkouts and returns are done by computers, not by people.)

So data integrity requires the cooperation of the database (to allow only valid values) and users (to enter the right values from all the possible ones).