Given:
$\mathrm{Homes}(\mathrm{home\_id},\mathrm{city},\mathrm{bedrooms},\mathrm{bathrooms},\mathrm{area})$
$\mathrm{Transactions}(\mathrm{home\_id},\mathrm{buyer\_id},\mathrm{seller\_id},\mathrm{transaction\_date},\mathrm{sale\_price})$
$\mathrm{Buyers}(\mathrm{buyer\_id},\mathrm{name})$
$\mathrm{Sellers}(\mathrm{seller\_id},\mathrm{name})$
Which SQL query returns a duplicate-free set of home IDs for homes that:
- are in Berkeley,
- have at least $6$ bedrooms,
- have at least $2$ bathrooms,
- were bought by $\text{'Bobby Tables'}$?
- $\mathrm{SELECT\ H.home\_id}$
$\mathrm{FROM\ Homes\ H,\ Transactions\ T,\ Buyers\ B}$
$\mathrm{WHERE\ H.home\_id=T.home\_id}$
$\mathrm{AND\ T.buyer\_id=B.buyer\_id}$
$\mathrm{AND\ H.city}=\text{'Berkeley'}$
$\mathrm{AND\ H.bedrooms}\geq 6$
$\mathrm{AND\ H.bathrooms}\geq 2$
$\mathrm{AND\ B.name}=\text{'Bobby Tables'}$;
- $\mathrm{SELECT\ DISTINCT\ H.home\_id}$
$\mathrm{FROM\ Homes\ H,\ Transactions\ T,\ Buyers\ B}$
$\mathrm{WHERE\ H.home\_id=T.home\_id}$
$\mathrm{AND\ T.buyer\_id=B.buyer\_id}$
$\mathrm{AND\ H.city}=\text{'Berkeley'}$
$\mathrm{AND\ H.bedrooms}\geq 6$
$\mathrm{AND\ H.bathrooms}\geq 2$
$\mathrm{AND\ B.name}=\text{'Bobby Tables'}$;
- $\mathrm{SELECT\ DISTINCT\ H.home\_id}$
$\mathrm{FROM\ Homes\ H,\ Transactions\ T,\ Buyers\ B}$
$\mathrm{WHERE\ H.home\_id=T.buyer\_id}$
$\mathrm{AND\ T.home\_id=B.buyer\_id}$
$\mathrm{AND\ H.city}=\text{'Berkeley'}$
$\mathrm{AND\ H.bedrooms}\geq 6$
$\mathrm{AND\ H.bathrooms}\geq 2$
$\mathrm{AND\ B.name}=\text{'Bobby Tables'}$;
- $\mathrm{SELECT\ DISTINCT\ H.home\_id}$
$\mathrm{FROM\ Homes\ H,\ Transactions\ T}$
$\mathrm{WHERE\ H.home\_id=T.home\_id}$
$\mathrm{AND\ H.city}=\text{'Berkeley'}$
$\mathrm{AND\ H.bedrooms}\geq 6$
$\mathrm{AND\ H.bathrooms}\geq 2$;