There are three basic operations to be performed on relations:
The INSERT Operation:
The insert operation allows us to insert a new tuple in a relation. When we try to insert a new record, then any of the following four types of constraints can be violated:
If the value given to an attribute lies outside the domain of that attribute.
If the value of the key attribute in the new tuple t is the same as in the existing tuple in relation R.
Entity Integrity Constraint:
If the primary key attribute value of new tuple is given as null.
Referential Integrity Constraint:
If the value of the foreign key in t refers to a tuple that does not appear in the referenced relation.
If the insertion violates one or more constraints then
The DELETION Operation:
- Insertion can be rejected and the reason for rejection can also be explained to the user by DBMS
- Ask the user to correct the data and resubmit, also give the reason for rejecting the insertion
Using the delete operation some existing records can be deleted from a relation. To delete some specific records from the database a condition is also specified, based on which records can be selected for deletion.
Constraints that can be violated during deletion
Only one type of constraint can be violated during deletion, it is referential integrity constraint. It can occur when delete a record in the table where it is referenced by the foreign key of another table.
If the deletion violates referential integrity constraint, then
The UPDATE Operation:
- Reject the deletion
- Attempt to cascade the deletion by deleting tuples that references the tuple that is being deleted
- Change the value of referencing attribute that causes the violation
Update operations are used for modifying database values.
The constraints violations faced by this operation are logically the same as the problem faced by Insertion and Deletion operations.