depts(DID(20), NAME(40), REGION(30)))All fields are CHAR except PRICE which is a FLOAT (which is represented using 20 characters).
depts_prods(DID(20), PID(20))
prods(NAME(40), PID(20), PRICE(20))
select depts.region, count(*)
from depts
group by depts.region
The second computes for each region how many products have been sold by departments in that region:
select depts.region, count(*)
from depts, depts_prods
where depts.did = depts_prods.did
group by depts.region
Turn in the following information for each of the two
queries: the
estimated running time and the actual running time. In addition,
indicate what join method the query optimizer selected for the second
query (i.e. you will say 'nested loop' or 'hash join' or ...).
For this and the following question you need to inspect the query plan.
Click on the corresponding button at the top of the Query Analyzer, or
hit CTRL-L. You also need to inspect the estimated cost: click on the
query plan's root node and read the 'subtree cost' (in seconds).
Finally, you need to measure the actual running time: this is shown by
the Query Analyzer at the bottom right; times under 1second are shown
as 0.
SELECT depts.region, avg(prods.price)Turn in the following: the query's answer, the estimated and actual running times, and the join methods selected by the query optimizer for the two joins.
FROM prods, depts_prods, depts
WHERE depts.did = depts_prods.did and
depts_prods.pid = prods.pid
GROUP BY depts.region
SELECT depts.region, depts_prods.didand
FROM depts, depts_prods
WHERE depts.did = depts_prods.did
SELECT count(*)
FROM depts, depts_prods
WHERE depts.did = depts_prods.did