CPSC340A
Database Systems

Activity 6

Unions

Sales Orders Database

  1. List the customers who ordered a helmet together with the vendors who provide helmets. (Hint: This involves creating a UNION of two complex JOINs.)

    +------------------------+------------------------------+----------+
    | FullName               | ProductName                  | RowID    |
    +------------------------+------------------------------+----------+
    | Viescas, Suzanne       | Viscount Microshell Helmet   | Customer |
    | Viescas, Suzanne       | Glide-O-Matic Cycling Helmet | Customer |
    | Viescas, Suzanne       | King Cobra Helmet            | Customer |
    | Thompson, William      | Glide-O-Matic Cycling Helmet | Customer |
    | Thompson, William      | Dog Ear Helmet Mount Mirrors | Customer |
    | Thompson, William      | King Cobra Helmet            | Customer |
    | Hallmark, Gary         | Glide-O-Matic Cycling Helmet | Customer |
    | Hallmark, Gary         | King Cobra Helmet            | Customer |
    | Hallmark, Gary         | Viscount Microshell Helmet   | Customer |
    | Hallmark, Gary         | Dog Ear Helmet Mount Mirrors | Customer |
    | Brown, Robert          | Glide-O-Matic Cycling Helmet | Customer |
    | Brown, Robert          | Viscount Microshell Helmet   | Customer |
    | Brown, Robert          | King Cobra Helmet            | Customer |
    | McCrae, Dean           | Glide-O-Matic Cycling Helmet | Customer |
    | McCrae, Dean           | King Cobra Helmet            | Customer |
    | McCrae, Dean           | Viscount Microshell Helmet   | Customer |
    | McCrae, Dean           | Dog Ear Helmet Mount Mirrors | Customer |
    | Viescas, John          | King Cobra Helmet            | Customer |
    | Viescas, John          | Glide-O-Matic Cycling Helmet | Customer |
    | Sergienko, Mariya      | Dog Ear Helmet Mount Mirrors | Customer |
    | Sergienko, Mariya      | Viscount Microshell Helmet   | Customer |
    | Sergienko, Mariya      | King Cobra Helmet            | Customer |
    | Sergienko, Mariya      | Glide-O-Matic Cycling Helmet | Customer |
    | Patterson, Neil        | Viscount Microshell Helmet   | Customer |
    | Patterson, Neil        | King Cobra Helmet            | Customer |
    | Patterson, Neil        | Glide-O-Matic Cycling Helmet | Customer |
    | Patterson, Neil        | Dog Ear Helmet Mount Mirrors | Customer |
    | Cencini, Andrew        | King Cobra Helmet            | Customer |
    | Cencini, Andrew        | Glide-O-Matic Cycling Helmet | Customer |
    | Cencini, Andrew        | Dog Ear Helmet Mount Mirrors | Customer |
    .
    .
    .
    (91 rows)

Bowling League Database

  1. Find the bowlers who had a raw score of 165 or better at Thunderbird Lanes combined with bowlers who had a raw score of 150 or better at Bolero Lanes. (Hint: This can also be solved with a UNION or a single SELECT statement and a complex WHERE clause.)

    +-------------------+----------------+-----------------+----------+
    | TourneyLocation   | BowlerLastName | BowlerFirstName | RawScore |
    +-------------------+----------------+-----------------+----------+
    | Thunderbird Lanes | Kennedy        | John            |      181 |
    | Thunderbird Lanes | Cunningham     | David           |      167 |
    | Thunderbird Lanes | Kennedy        | John            |      175 |
    | Thunderbird Lanes | Cunningham     | David           |      178 |
    | Thunderbird Lanes | Patterson      | Neil            |      179 |
    | Thunderbird Lanes | Viescas        | David           |      181 |
    | Thunderbird Lanes | Patterson      | Kathryn         |      180 |
    | Thunderbird Lanes | Viescas        | David           |      183 |
    | Thunderbird Lanes | Patterson      | Kathryn         |      177 |
    | Thunderbird Lanes | Viescas        | David           |      178 |
    | Thunderbird Lanes | Viescas        | John            |      189 |
    | Thunderbird Lanes | Thompson       | Mary            |      180 |
    | Thunderbird Lanes | Thompson       | William         |      167 |
    | Thunderbird Lanes | Viescas        | John            |      176 |
    | Thunderbird Lanes | Thompson       | Mary            |      175 |
    | Thunderbird Lanes | Thompson       | William         |      178 |
    | Thunderbird Lanes | Thompson       | Sarah           |      168 |
    | Thunderbird Lanes | Patterson      | Rachel          |      179 |
    | Thunderbird Lanes | Viescas        | Caleb           |      193 |
    | Thunderbird Lanes | Thompson       | Sarah           |      178 |
    .
    .
    .
    (129 rows)