Junior — Middle
Can you explain what is meant by data integrity in a database?
sobes.tech AI
Answer from AI
Data integrity in a database is a set of rules and mechanisms that ensure the correctness, consistency, and reliability of data.
Main types of integrity:
- Entity integrity — guarantees that each record is unique (for example, through a primary key).
- Referential integrity — ensures the correctness of relationships between tables (for example, a foreign key must reference an existing record).
- Domain integrity — data in a column conforms to a specific type and range of values.
For example, if the "Orders" table has a foreign key to the "Customers" table, you cannot add an order with a non-existent customer — this maintains referential integrity.