edited by
10,516 views
60 votes
60 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
edited by

5 Answers

Best answer
38 votes
38 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
65 votes
65 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
11 votes
11 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.
8 votes
8 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
Answer:

Related questions

7 votes
7 votes
3 answers
1
go_editor asked Feb 8, 2018
1,986 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...
16 votes
16 votes
2 answers
3
Kathleen asked Sep 14, 2014
3,687 views
Consider a relation examinee (regno, name, score), where regno is the primary key to score is a real number.Write a relational algebra using $( \Pi, \sigma, \rho, \times)...
52 votes
52 votes
3 answers
4
Kathleen asked Sep 14, 2014
7,257 views
Let r and s be two relations over the relation schemes R and S respectively, and let A be an attribute in R. The relational algebra expression $\sigma_{A=a}(r \bowtie s)...