GATE CSE
First time here? Checkout the FAQ!
x
+8 votes
500 views

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 empIds of employees whose age is greater than that of

(A) some dependent.

(B) all dependents.

(C) some of his/her dependents.

(D) all of his/her dependents.

asked in Databases by Veteran (73.2k points)   | 500 views

2 Answers

+19 votes
Best answer
(D) all of his/her dependents.

The inner query selects the employees whose age is less than or equal to at least one of his dependents. So, subtracting from the set of employees, gives employees whose age is greater than all of his dependents.
answered by Veteran (272k points)  
What's wrong in option B.Its also selecting all dependents value.
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.
–2 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"

answered by Loyal (3.1k points)  

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"

Answer:

Related questions

Top Users Jan 2017
  1. Debashish Deka

    7050 Points

  2. Habibkhan

    4674 Points

  3. Vijay Thakur

    4224 Points

  4. saurabh rai

    4008 Points

  5. sudsho

    3960 Points

  6. Arjun

    3108 Points

  7. GateSet

    3088 Points

  8. santhoshdevulapally

    3004 Points

  9. Bikram

    2976 Points

  10. Sushant Gokhale

    2744 Points

Monthly Topper: Rs. 500 gift card

18,810 questions
23,779 answers
51,413 comments
20,128 users