1,185 views

Relation Schema :

• Employee (Name, Ssn, Bdate, Address, Dept_number)
• Project (Pname, Pno, Dept_number)
• WorksOn (Essn, Pno, Hours)

List the names of employees who work on all the projects controlled by department number 10.

$\left \{ e.Name | Employee(e) \land \exists\ p(Project(p) \land p.Dept\_number = 10) \land (\forall p ( \exists w ( worksOn(w) \land w.Pno = p.pno \land w.Essn = e.ssn))) \right \}$

Please confirm if it is correct or not

The solution provided was :

$\left \{ e.Name | Employee(e) \land (\forall x (Project (x) \land x.Dept\_number = 10 )) \to (\exists w)(WorksOn(w) \land w.Essn = e.ssn \land x.Pno = w.Pno) \right \}$

However, I think that it will also print unnecessary values of employee name because for the "implies" part, if the LHS becomes false (may be because x.Dept_number = 5 ), then all of the "implies" part will be evaluated to True and thus those employees name will be printed who work for some project at department no. 5 and not for the department no. 10 ?

### 1 comment

@  could you confirm ??

@Harsh

in solution provided -Assume atleast one project is controlled by department no. 10 then only this query gives

correct result otherwise it will be very complex to write down such a query .

I would like to know if you also verified my answer....
why are you attaching the same variable p to both existential and universal quantifier? I mean is that allowed?

Yes you are correct,it is not a safe query. for it to be correct the implies should exclude employee(e) as below.

{e.Name|Employee(e)∧((∀x(Project(x)∧x.Dept_number=10))→(∃w)(WorksOn(w)∧w.Essn=e.ssnx.Pno=w.Pno))}

### 1 comment

I think for all should include whole implies statement not only LHS of implies statement. So the brackets in the query should be as follows,

{e.Name|Employee(e)∧(∀x((Project(x)∧x.Dept_number=10)→(∃w)(WorksOn(w)∧w.Essn=e.ssnx.Pno=w.Pno)))}

Please correct me if I am wrong.

1 vote