Data integrity
The INSERT, UPDATE, and DELETE statements modify data in an existing database. Whenever you modify existing data, the integrity of the data can be affected. For example, an order for a nonexistent product could be entered into the orders table, a customer with outstanding orders could be deleted from the customer table, or the order number could be updated in the orders table and not in the items table. In each of these cases, the integrity of the stored data is lost.
Data integrity is actually made up of the following parts:
- Entity integrity
- Each row of a table has a unique identifier.
- Semantic integrity
- The data in the columns properly reflects the types of information the column was designed to hold.
- Referential integrity
- The relationships between tables are enforced.
Well-designed databases incorporate these principles so that when you modify data, the database itself prevents you from doing anything that might harm the integrity of the data.