The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+29 votes

Consider a relation geq which represents "greater than or equal to", that is, $(x,y) \in $ geq only if $y \geq x$.

create table geq
    ib	integer	not null,
    ub	integer	not null,
    primary key ib,	
    foreign key (ub) references geq on delete cascade

Which of the following is possible if tuple (x,y) is deleted?

  1. A tuple (z,w) with z > y is deleted
  2. A tuple (z,w) with z > x is deleted
  3. A tuple (z,w) with w < x is deleted
  4. The deletion of (x,y) is prohibited
asked in Databases by Veteran (59.5k points)
edited by | 1.9k views

Solution becomes easier by taking examples


5 Answers

+23 votes
Best answer

Answer: C

The table can be depicted as:

ib (PK) ub (FK)
$z$ $w=u$
$u$ $v=x$
$x$ $y$

If $(x,y)$ is deleted then from the above table:

  • $v\leq y$ $($as $v=x)$
  • $u<v\leq y, u!=v$ $($as $v=x$ and ib is the Primary Key$)$
  • $w<v\leq y$ $($as $w=u)$
  • $z<w<v\leq y, z!=w$ $($as $w=u$ and ib is the Primary Key$)$

As, it can be seen that $w<v$ or $w<x$ $($as $v=x)$ so C is the answer.

answered by Boss (34k points)
edited by
How C?
Hey Rajarshi,how are you assuming is w=u? and v=x? of couse if it is so, then definitely obvious. Also the question says x>w, it should have been x>=w. w != x, so how can we deduce?
After seeing this question i got know clue how to approach this one.Can u suggest how did u think of this way?

and please cite some source from where i can learn to solve this type of questions?
@Bikram Sir @Arjun Sir, Little confusion please clarify 'y' is an element in ub which is a foreign key that means it should hold those elements which are present in lb but there is no 'y' in lb?
Thank you, very well explained. :)
If we have relation instance like below.

ib           ub
1              2
2              2
3              3

And we delete (3, 3) then what would be the result?


I wonder this is the case where option C does not hold. But there are cases in which option C is true too.

Now as we have asked 'which option is possible' the answer is C.
Let the tuples are

x y
l m
z w
Such that m=x and w=l then the relation among the values such that the tuples can insert in the relation so that it satisfies the given relation is. z <=w=l <=m=x <=y .so this relation only satisfied by option C.
+9 votes

tuple (x,y) is to be deleted so let's take it into relation.

Now we have to observe the effect on tuple (z,w) so we will take it also in our table.

So till now, we are having two tuples, (x,y) and (z,w). Now let's consider each option:

a) z>y means (y,z) tuple is there. So deletion of (x,y) doesn't give any cascade relation between (x,y),(z,w) and (y,z) 

b) z>x means (x,z) exists in relation. But since 'ib' is primary key, we can't repeat 'x' .

c) w<x means (w,x) exists. On deleting (x,y), (w,x) should be deleted and then (z,w) to maintain DELETE CASCADE. 

Hence option C is correct choice

answered by Active (1.6k points)
edited by
if u have any material related to this topic then pls send me that link.
No as such link, just go through the concepts of "Referenced integrity constraints"...u will get everything required...
thank u
This is the best answer. Thank you!
+8 votes
ans is C.

here they have mentioned "on delete cascade"

deleting (x,y), the relation having x as a greater value will also b deleted. in (z,w) w<x (x is greater) therefore it will also be deleted.
answered by Loyal (8.2k points)
Thanks for explanation
how w < x, if w =  x, then it will get deleted
+4 votes
Answer is (C)
Take following table as an example:
ib    ub
10  10
7     10
4     10

Now delete 10,10(x,y)
7,10 (z,w)
are deleted too!
And w < x, that's all!
answered by Boss (17k points)
@Vijay for the above example 7 & 4 are z not w.pls make me correct if I am wrong.


        id(x)                ub(y)       
         10         10
          7         10
          4         10 


        id(z)                ub(w)       
         10         10
          7         10
          4         10

on deleting (10,10)=(x,y)

yes (7,10) and (4,10) will be deleted.

so let take (7,10)=(z,w)

here z<x(7<10), z<y(7<10) and w=x(10=10)

same thing for (4,10)

then how (C) option is correct??  

C. A tuple (z,w) with w < x is deleted


what that's all ??
ur example are showing w=x not w<x !!!!!

+4 votes

Consider the below example 

lb ub
5 8
3 5
8 8
2 3

Deleting first tuple will force us to delete 2 nd tuple

And deleting 2 nd tuple will force us to delete 4 th tuple.

Now because of deletion of first tuple (5,3), 4 th tuple (2,3) should be deleted ... Here z = 2 and x = 5 and z<x

So option C) is the answer ...

answered by Loyal (7.3k points)
edited by

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

39,481 questions
46,655 answers
57,350 users