The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+28 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?

- A tuple (z,w) with z > y is deleted
- A tuple (z,w) with z > x is deleted
- A tuple (z,w) with w < x is deleted
- The deletion of (x,y) is prohibited

+21 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<=y (as v=x)
- u<v<=y, u!=v (as v=x and ib is the Primary Key)
- w<v<=y (as w=u)
- z<w<v<=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.

+2

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?

0

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?

and please cite some source from where i can learn to solve this type of questions?

+9 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.

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.

+6 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

+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)

4,10(z,w)

are deleted too!

And w < x, that's all!

Take following table as an example:

ib ub

10 10

7 10

4 10

Now delete 10,10(x,y)

7,10 (z,w)

4,10(z,w)

are deleted too!

And w < x, that's all!

+3 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 ...

- All categories
- General Aptitude 1.2k
- Engineering Mathematics 5k
- Digital Logic 2k
- Programming & DS 3.6k
- Algorithms 3.1k
- Theory of Computation 3.9k
- Compiler Design 1.5k
- Databases 2.9k
- CO & Architecture 2.5k
- Computer Networks 2.9k
- Non GATE 1k
- Others 1.4k
- Admissions 412
- Exam Queries 419
- Tier 1 Placement Questions 17
- Job Queries 55
- Projects 9

34,943 questions

41,958 answers

119,194 comments

41,472 users