GATE | GATE-CS-2001 | Question 50
Consider a relation geq which represents “greater than or equal to”, that is, (x,y) ∈ geq only if y >= x.
create table geq ( ib integer not null ub integer not null primary key 1b foreign key (ub) references geq on delete cascade )
Which of the following is possible if a tuple (x,y) is deleted?
(A) A tuple (z,w) with z > y is deleted
(B) A tuple (z,w) with z > x is deleted
(C) A tuple (z,w) with w < x is deleted
(D) The deletion of (x,y) is prohibited
Explanation: In the above question, the relation schema is ( lb , ub ), where lb is the primary key, and ub is the foreign key which is referencing the primary key of its own relation.
Hence the table geq is both the master ( which has the referenced key ) as well as the child table (which has the referencing key).
The table has two constraint, one is that if there is a tuple ( x, y ), then y is greater than or equal to x, And the other is referential integrity constraint, which is on-cascade-delete on the foreign key.
On-cascade-delete says, that “When the referenced row is deleted from the other table (master table), then delete also from the child table”.
Suppose the instance in the given relation is the following: x y ----- 5 6 4 5 3 4 6 6
Now if we delete tuple (5,6) then tuple ( 4,5 ) should also be deleted ( as 5 in the tuple (4, 5) was referencing to 5 in the tuple(5,6) which no longer exist, hence the referencing tuple should also be deleted), and as (4,5) got deleted hence tuple (3,4) should also be deleted for the same reason.
Therefore in total 3 rows have to be deleted if tuple ( 5,6 ) is deleted.
Now from the above instance we can say that if (x,y), i.e. ( 5,6 ) gets deleted then a tuple ( z, w) i.e, ( 3, 4) is also deleted. And we can see here that w < x. Hence option C.
Quiz of this Question