728 views
1 votes
1 votes

Emp (Eid, name, age)

Project(Pid, Pname, budget)

Works(Eid, Pid)

Select Eid from Emp E where age>30 not exists (Select Pid from Project P where Pname="database" and not exists (select Pid from Works W where W.Eid=E.Eid and W.Pid=E.Pid));

Above query retrieves employees whose

a) age more than 30 and works for every project  with project name database.

b) age more than 30 and works for some project with project name database.

c) age more than 30 and not works for every project with project name database.

d) age more than 30 and not works for any project with project name database. 

here Eid and Pid in every table is primary key.

answer given is option a, but i have doubt because am getting option b. someone please clarify my doubt with example.

1 Answer

1 votes
1 votes

This is an example of Double Nested NOT EXISTS query. That is, it has a NOT EXISTS clause within a 

NOT EXISTS clause. Formally, it answers the question “does an employee exist with projectname Database and a project that is not in Works”? But it is easier to say that a nested NOT EXISTS answers the question 

“is x TRUE for all y?”

In our case, that is equivalent to "Find the employees whos age is more than 30 and works for every project  with project name database"

Related questions

0 votes
0 votes
1 answer
1
Mrityudoot asked Jan 12
147 views
Isn’t F$^{+}$ minimal cover? If C $\rightarrow$ A is already there, then why does augmented CD $\rightarrow$ A needs to be?
0 votes
0 votes
1 answer
2
1 votes
1 votes
1 answer
3
Sajal Mallick asked Nov 5, 2023
361 views
Unique not null is equivalent to primary key.Relational Algebra and SQL has same expressive power.Which of the above statements are False?
2 votes
2 votes
1 answer
4
kaustubh7 asked Sep 20, 2023
448 views
Consider a relation R having seven attributes ABCDEFG. Fields of R contain only atomic values.FDs = {CD → G, A → BC, B → CF, E → A, F → EG, G → D} is set of f...