Consider a relation geq which represents “greater than or equal to”, that is,…
2001
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
Attempted by 26 students.
Show answer & explanation
Correct answer: C
The attribute ub is a foreign key referencing lb in the same table.
Because the constraint uses ON DELETE CASCADE, deleting a tuple (x,y) automatically deletes all tuples whose ub = x.
Therefore, dependent tuples can be removed as a result of the cascading delete operation.
(z,w) references (x,y), then:
w = x
because ub references lb.
When (x,y) is deleted, all tuples having:
ub = x
are deleted due to ON DELETE CASCADE.
Since geq requires:
z ≤ w
and here:
w = x
it follows that:
z ≤ x
and possibly:
z < x
Thus tuples with w = x (and therefore not greater than x) can indeed be deleted.