780 views
2 votes
2 votes

Consider the database Employee with underlined primary key,
Employee (employee_name, street, city)
Works (employee_name, company_name, salary)
Company (company_name, city)
Manages (employee_name, manager_name)
Assume that companies may be located in several city. We need to find all companies located in every city in which ‘Made Easy’ is located

Consider these statement about Query-1 and Query-2.

1 Answer

0 votes
0 votes
as we can see that query-1 results in all the companies which are either not located in any city where 'madeeasy' is located or located in some cities where madeeasy is located but not selecting the company which is located in every city where made easy is located.

query-2; here selection is done if inner query results null.

inner query is made up of two sub-query, lets say q2 and q3.

q2 is working independently whereas q3 is nested with outer query.{whole query works like q1(q2-q3)}.

q2 results in all the city where 'madeeasy' is located.

q3 results in all the city where company from outer query is located.

if q2-q3=empty, it means company is located in all the city where 'madeeasy' is located + it may also be located in some other city.

and so particular company from outer query will be selected.

Related questions

1 votes
1 votes
1 answer
2
khushtak asked Jan 20, 2016
823 views
Can anyone suggest me how to learn about sql and relational algebra and calculus for gate?as i feel this is an important topic and one 2 marks ques will be asked. I can u...