(D) is **partially **true, because, if t**here are such employees who don't have any dependent**, they will also be selected in the final result set.

The Gateway to Computer Science Excellence

First time here? Checkout the FAQ!

x

+27 votes

Consider the relational schema given below, where **eId** of the relation **dependent** is a foreign key referring to **empId** of the relation **employee**. Assume that every employee has at least one associated dependent in the **dependent** relation.

**employee (empId, empName, empAge)**

**dependent (depId, eId, depName, depAge)**

Consider the following relational algebra query:

$\Pi_{empId}\:(employee) - \Pi_{empId}\:(employee \bowtie_{(empId=eID) \wedge (empAge \leq depAge)} dependent)$

The above query evaluates to the set of **empId**s of employees whose age is greater than that of

- some dependent.
- all dependents.
- some of his/her dependents.
- all of his/her dependents.

+37 votes

Best answer

+15

if $empId=eID$ this condition won't be there in question, then answer will be B. But in this case if any employee E1 is selected that means E1 age is greater than all of E1's dependent, E1 age might be smaller/greater than E2's dependent.

+1

Option B means the employees who are senior than all dependents.

Option D means that employees who are senior than only their dependents. (when empid=eid).

Option D means that employees who are senior than only their dependents. (when empid=eid).

+2

employee:

empid | empAge |

e1 | 20 |

e2 | 50 |

e3 | 40 |

dependent:

did | eid | dAge |

d1 | e1 | 30 |

d2 | e2 | 35 |

d3 | e2 | 60 |

d4 | e3 | 35 |

d5 | e3 | 30 |

inner query returns (e1,e2)

subtracting from emp gives e3, whose age is greater than all his/her dependents.

0

@Sachin Mittal 1 sir,

Is this right

set of **empId**s of employees whose age is greater than that of

1**.some dependent.**

$\prod$ empId ( employee ⋈ ( empAge > depAge ) dependent )

**2.all dependents.**

$\prod$empId(employee) − $\prod$ empId ( employee ⋈ (empAge ≤ depAge ) dependent )

**3.some of his/her dependents.**

$\prod$empId(employee ⋈ ( empId = eID ) ∧ ( empAge > depAge ) dependent )

**4.all of his/her dependents.**

$\prod$empId(employee) − $\prod$ empId ( employee ⋈ ( empId = eID ) ∧ ( empAge ≤ depAge ) dependent

0

@92komal @Brij Mohan Gupta @Shubham Aggarwal "**eId** of the relation **dependent** is a foreign key referring to **empId** of the relation **employee" **from this line of the question we can distinguish between option (B) and option (D) see how:

We know that in foreign key something can be Missed or Repeated (i.e with respect to primary key obviously) but nothing can be added extra (i.e keeping in mind referential integrity constraint).

So, take the case of repeated values in foreign key. You can easily get option (D) is correct.

Please mention if this way is wrong.

0 votes

(C) some of his/her dependents

consider the qN as A-B

B select all the empID with age which is less than all his dependends

so subtracting above from the universal set give the opposite of which is "empID with age greater than atleast one of his dependents"

+3

Procedure is correct. But

"B select all the empID with age which is less than all his dependends"

is wrong. Select statement returns empID even if it is true for at least one of the dependent. So, in B it is "some" and in A-B it will be "All"

0

0

@ manu00x I understand that, but if it were possible that employee may or may not have a dependent then what would be the answer..

- All categories
- General Aptitude 1.6k
- Engineering Mathematics 7.5k
- Digital Logic 3k
- Programming & DS 4.9k
- Algorithms 4.3k
- Theory of Computation 6k
- Compiler Design 2.1k
- Databases 4.2k
- CO & Architecture 3.5k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.5k
- Admissions 586
- Exam Queries 572
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,129 questions

53,252 answers

184,785 comments

70,506 users