in Databases
775 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.

in Databases
775 views

1 comment

@Shaik can u pls verify whether the first query is right or not?
0
0

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