edited by
20,064 views
85 85 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

9 Answers

Best answer
53 53 votes

Answer: C

The table can be depicted as:

$$\begin{array}{|c|c|c|} \hline \textbf{ib(PK)} & \textbf {ub(FK)} \\\hline  \text {z} &  \text{w = u}\\\hline  \text{u} & \text{v = x} \\\hline \text{x} & \text{y}  \\\hline \end{array}$$

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.

edited by
94 94 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

edited by
13 13 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 ...

edited by
12 12 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.
1 1 vote
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.
1 1 vote
i want to add just hint here think transitively if (x,y) is deleted then pk x is deleted therefore all the tuple which have x in forein they willl be deleted and because of these all the tuples having those tuples pk as forein key they will be deleted try to visualize you will get answer
Answer:
Position:
Show:

Related questions

12 12 votes
3 answers 3 answers
4.2k
4.2k views
go_editor asked Feb 8, 2018
4,233 views
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.Write an SQL query to list the regno of examinees who have a s...
12 12 votes
3 3 answers
4.2k
4.2k views
go_editor asked Feb 8, 2018
4,247 views
Consider a relation $\text{examinee (regno, name, score)},$ where regno is the primary key to score is a real number.Suppose the relation $\text{appears (regno, centr_cod...
61 61 votes
9 answers 9 answers
16.5k
16.5k views
Kathleen asked Sep 14, 2014
16,527 views
Which of the following relational calculus expression is not safe?$\left\{t \mid \exists u \in R_1\left(t[A] = u[A]\right) \land \neg \exists s \in R_2 \left(t[A] = s[A]\...
185 185 votes
8 answers 8 answers
78.7k
78.7k views
Kathleen asked Sep 14, 2014
78,735 views
$R(A,B,C,D)$ is a relation. Which of the following does not have a lossless join, dependency preserving $BCNF$ decomposition?$A \rightarrow B, B \rightarrow CD$$A \righta...