Data integrity means keeping data accurate, complete, consistent, and in its intended state. Think of a database as a guard dog: it should stop an order from pointing to a customer who does not exist, rather than let a ghost customer haunt the records. section 8.2.1
In a relational database, a strict schema defines the structure of tables up front. Built-in constraints reject invalid writes, keeping bad or incomplete data out of storage. section 8.2.1
Keys provide two important guardrails:
- A primary key identifies each row. Its value must be unique and cannot be null. section 8.2.1
- A foreign key explicitly links a column to a primary key in another table. Naming a column CustomerId is not enough: the constraint must be created for the database to enforce the link. section 8.2.1
Orders and customers
An Orders table can use CustomerId as a foreign key to Customers.Id. The database then refuses an order for a nonexistent customer, preventing an orphaned record. The constraint also acts as a safety net against deleting a customer who still has open orders. section 8.2.1
Figure 8.2 Showing how Primary Keys and Foreign Keys work together to link tables. The child table (Orders) uses the Customer_ID as a Foreign Key to point directly back to its parent record (Customers), establishing a clear one-to-many relationship.

See how primary and foreign keys connect customers to their orders. section 8.2.1
Normalization supports a clearer structure: store a customer’s address once in an Address table and link to it instead of duplicating it in every order. Integrity is also an architectural constraint: a quick internal tool may trade scalability for speed, but finance and healthcare can make integrity non-negotiable. section 8.2.1 section 2.5.1




















