About this interactive
A database stores records in tables, and a relational database ties tables together, such as a users table and a companies table joined by a third table that links them. If the data in those tables is wrong, names get misspelled in emails, the same company appears three times, and marketing goes to the wrong zip code. The lesson named four kinds of integrity that guard against it.
Entity integrity is about the primary key, the ID that identifies each record. It must be unique: two records with the same ID means the database cannot pull the right one. Domain integrity is about the format of each column: every zip code five digits, every state two letters, every quantity a number. Referential integrity is about the links between tables: a record that ties a user to a company needs both of them to exist, so deleting one while the link remains breaks it. User-defined integrity is the rules the business chooses for itself, such as checking a new sign-up's email so the same person is not entered twice.
Two pairs are easy to mix up. A duplicate ID is entity integrity, but a duplicate person with two different IDs is a user-defined rule, because the database only knows they are the same person if the business tells it what to check. And a value in the wrong format is domain integrity, while a value pointing to a record that is not there is referential integrity.
About TechKnowSurge
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →