1,149 views
1 1 vote

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 1 vote

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"

Position:
Show:

Related questions

0 0 votes
0 0 answers
453
453 views
Prem Sai Kodi asked Jan 22
453 views
I'm confused about this...help me... 
0 0 votes
0 0 answers
474
474 views
DTYDHTB asked Dec 12, 2025
474 views
Consider a database system where transactions are executed concurrently. If transaction T1 holds an exclusive lock on resource R1 and requests a shared lock on resource R...
0 0 votes
0 0 answers
590
590 views
Naman_Chandel asked Dec 4, 2025
590 views
In a universally database, there are entity sets: Student (SID, Name, Dept), Professor (PID, Name, Dept), Course (CID, Title) and Project (ProjID, Topic). Student registe...
0 0 votes
0 0 answers
232
232 views
Sarthak_Joshi asked Jul 18, 2025
232 views
Consider the following interleaved schedule S involving transaction T₁, T₂ on data item X and Y.S: R₁(X); W₁(X); R₂(X); W₂(X); R₂(Y); W₂(Y); R₁(Y); W₁(Y); C₂, C₁Where R(X...