in Databases edited by
1,185 views
1 vote
1 vote

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.

My Answer : 

$\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 ?

in Databases edited by
1.2k views

1 comment

@  could you confirm ??

0
0

2 Answers

0 votes
0 votes

@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 .

2 Comments

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

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.

0
0

Related questions