What is integrity?
- SQL course
- Intermediate
- Lesson 94/115
- 4 min
Learn the concept of data consistency.
What is integrity?
Data integrity keeps data correct and consistent. It prevents invalid entries.
-- Entity: PRIMARY KEY
-- Referential: FOREIGN KEY
-- Domain: CHECK + NOT NULLThree integrity types.
What is integrity? — details
If integrity breaks, data becomes inconsistent. JOINs give wrong results, reports mislead.
For example, if orders of a deleted customer remain, reports show sales with no owner; constraints prevent such inconsistencies up front.
Practice What is integrity?
Add a CHECK on balance in accounts: no negative values.
Starter code
-- add integrity
ALTER TABLESample solution
ALTER TABLE accounts
ADD CHECK (balance >= 0)Expected output
Tablo güncellendi
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What does data integrity ensure?
- Consistency Correct answer
- Speed
- Sorting
- Compression
Explanation: Data integrity ensures consistency.
2 Integrity
Data ____ keeps data consistent
Data integrity keeps data consistent
Explanation: Data integrity keeps data consistent.
3 What is integrity: match the terms
| Term | Meaning |
|---|---|
entity |
entity |
referential |
reference |
domain |
domain |
trigger |
trigger |