CSC210F2020ASyllabusHome2

From BU Computer Science
Jump to navigation Jump to search

SQL Homework 2

This homework uses the sailors data

Only turn in the sql statements (not the results of the query). You may test your queries out online. (But remember, just because you get the right data back, that does not mean your query is correct!). Turn in an electronic copy or your .sql file.

Questions:
Part A: Single Table Queries

  1. How many red boats are there?
  2. How many different times has each boat been reserved?
  3. What is the date of the earliest reservation?
  4. What is the current highest rating?
  5. What is the age of the youngest person?

Part B: Use only joins

  1. Find the names of sailors who have reserved boat number 103.
  2. Find the sids of sailors who have reserved a red boat.
  3. Find the names of sailors who have reserved a red boat.
  4. Find the colors of boats reserved by Lubber.
  5. Find the names of sailors who have reserved at least one boat.
  6. Find the names of sailors who have reserved a red or a green boat.
  7. Find the names of sailors who have reserved both a red and a green boat.
  8. Find the sids of all sailors who have reserved red boats but not green boats. This cannot be done with a join. Extra credit if you can explain why. (Don't give an sql for this -> skip if you are not doing extra credit)
  9. Find all sids of sailors who have a rating of 10 or reserved boat 104.