When we want to create a relational database, we must comply with four integrity constraints in order for our DB to work correctly.
- Entity integrity constraint. A PK (Primary Key) cannot allow null values
- Enforcement: check for null values when enter data.
- Key integrity constraint. No two tuples can have the same attribute value.
- Enforcement: check duplicity.
- Referential integrity constraint. We cannot have any unmatched FK (Foreign Key). That is, if B references A, A must exist.
- Enforcement:
- Restriction. The Update/delete of PK is restricted to not having a matching FK.
- Nullification. Update/delete of PK can only be done after setting any FK to null.
- Cascading. Update/delete of PK cascades to any FK.
- Semantic integrity constraint. We must use data that makes sense. We look for semantic correctness.
- Enforcement: use restrictions when enter data such as: length, legal values (i.e. car brands), types of data (i.e. currency, date, etc.), range, etc.
Comentarios
Publicar un comentario