1.

Suppose There Are Two Relations R And S, Such That The Foreign Key B Of R References The Primary Key A Of S. Describe How The Trigger Mechanism Can Be Used To Implement The On Delete Cascade Option, When A Tuple Is Deleted From S?

Answer»

We define TRIGGERS for each relation whose primary-key is REFERRED to by the foreign-key of some other relation. The trigger would be activated WHENEVER a tuple is deleted from the referred-to relation. The action PERFORMED by the trigger would be to visit all the referring relations, and delete all the tuples in them whose foreign-key attribute value is the same as the primary-key attribute value of the deleted tuple in the referred-to relation. These SET of triggers will take care of the on delete cascade operation.

We define triggers for each relation whose primary-key is referred to by the foreign-key of some other relation. The trigger would be activated whenever a tuple is deleted from the referred-to relation. The action performed by the trigger would be to visit all the referring relations, and delete all the tuples in them whose foreign-key attribute value is the same as the primary-key attribute value of the deleted tuple in the referred-to relation. These set of triggers will take care of the on delete cascade operation.



Discussion

No Comment Found

Related InterviewSolutions