CPSC340A
Database Systems

Activity 1

Select

Sales Orders Database

  1. Show me all the information on our employees.

    +------------+--------------+-------------+-------------------------+-------------+----------+------------+-------------+----------------+--------------+
    | EmployeeID | EmpFirstName | EmpLastName | EmpStreetAddress        | EmpCity     | EmpState | EmpZipCode | EmpAreaCode | EmpPhoneNumber | EmpBirthDate |
    +------------+--------------+-------------+-------------------------+-------------+----------+------------+-------------+----------------+--------------+
    |        701 | Ann          | Patterson   | 16 Maple Lane           | Auburn      | WA       | 98002      |         253 | 555-2591       | 1958-03-18   |
    |        702 | Mary         | Thompson    | 122 Spring River Drive  | Duvall      | WA       | 98019      |         425 | 555-2516       | 1990-06-21   |
    |        703 | Matt         | Berg        | 908 W. Capital Way      | Tacoma      | WA       | 98413      |         253 | 555-2581       | 1964-11-02   |
    |        704 | Carol        | Viescas     | 722 Moss Bay Blvd.      | Kirkland    | WA       | 98033      |         425 | 555-2576       | 1987-12-23   |
    |        705 | Kirk         | DeGrasse    | 455 West Palm Ave       | San Antonio | TX       | 78284      |         210 | 5552311        | 1985-10-05   |
    |        706 | David        | Viescas     | 16679 NE 42nd Court     | Redmond     | WA       | 98052      |         425 | 555-2661       | 1968-01-01   |
    |        707 | Kathryn      | Patterson   | 554 E. Wilshire
    Apt. 2A | Seattle     | WA       | 98105      |         206 | 555-2697       | 1982-12-12   |
    |        708 | Susan        | McLain      | 511 Lenora Ave          | Bellevue    | WA       | 98006      |         425 | 555-2301       | 1967-10-15   |
    +------------+--------------+-------------+-------------------------+-------------+----------+------------+-------------+----------------+--------------+
    (8 rows)
  2. Show me a list of cities, in alphabetical order, where our vendors are located, and include the names of the vendors we work with in each city.

    +--------------+------------------------+
    | VendCity     | VendName               |
    +--------------+------------------------+
    | Albany       | ProFormance            |
    | Anchorage    | Big Sky Mountain Bikes |
    | Ballard      | Nikoma of America      |
    | Bellevue     | Shinoman, Incorporated |
    | Dallas       | Armadillo Brand        |
    | El Paso      | Lone Star Bike Supply  |
    | New York     | Dog Ear                |
    | Redmond      | Kona, Incorporated     |
    | Santa Monica | Sun Sports Suppliers   |
    | St. Louis    | Viscount               |
    +--------------+------------------------+
    (10 rows)

Entertainment Agency Database

  1. Give me the names and phone numbers of all our agents, and list them in last name/first name order.

    +-------------+--------------+----------------+
    | AgtLastName | AgtFirstName | AgtPhoneNumber |
    +-------------+--------------+----------------+
    | Bishop      | Scott        | 555-2666       |
    | Dumbwit     | Daffy        | 555-1234       |
    | Kennedy     | John         | 555-2621       |
    | Patterson   | Maria        | 555-2291       |
    | Smith       | Karen        | 555-2551       |
    | Thompson    | William      | 555-2681       |
    | Viescas     | Caleb        | 555-0037       |
    | Viescas     | Carol        | 555-2571       |
    | Wier        | Marianne     | 555-2606       |
    +-------------+--------------+----------------+
    (9 rows)
  2. Give me the information on all our engagements.

    +------------------+------------+------------+-----------+----------+---------------+------------+---------+---------------+
    | EngagementNumber | StartDate  | EndDate    | StartTime | StopTime | ContractPrice | CustomerID | AgentID | EntertainerID |
    +------------------+------------+------------+-----------+----------+---------------+------------+---------+---------------+
    |                2 | 2012-09-01 | 2012-09-05 | 13:00:00  | 15:00:00 |        200.00 |      10006 |       4 |          1004 |
    |                3 | 2012-09-10 | 2012-09-15 | 13:00:00  | 15:00:00 |        590.00 |      10001 |       3 |          1005 |
    |                4 | 2012-09-11 | 2012-09-17 | 20:00:00  | 00:00:00 |        470.00 |      10007 |       3 |          1004 |
    |                5 | 2012-09-11 | 2012-09-14 | 16:00:00  | 19:00:00 |       1130.00 |      10006 |       5 |          1003 |
    |                6 | 2012-09-10 | 2012-09-14 | 15:00:00  | 21:00:00 |       2300.00 |      10014 |       7 |          1008 |
    |                7 | 2012-09-11 | 2012-09-18 | 17:00:00  | 20:00:00 |        770.00 |      10004 |       4 |          1002 |
    |                8 | 2012-09-18 | 2012-09-25 | 20:00:00  | 23:00:00 |       1850.00 |      10006 |       3 |          1007 |
    |                9 | 2012-09-18 | 2012-09-28 | 19:00:00  | 21:00:00 |       1370.00 |      10010 |       2 |          1010 |
    |               10 | 2012-09-17 | 2012-09-26 | 13:00:00  | 17:00:00 |       3650.00 |      10005 |       3 |          1003 |
    |               11 | 2012-09-15 | 2012-09-16 | 18:00:00  | 00:00:00 |        950.00 |      10005 |       4 |          1008 |
    |               12 | 2012-09-18 | 2012-09-26 | 18:00:00  | 22:00:00 |       1670.00 |      10014 |       8 |          1001 |
    |               13 | 2012-09-17 | 2012-09-20 | 20:00:00  | 23:00:00 |        770.00 |      10003 |       1 |          1006 |
    |               14 | 2012-09-24 | 2012-09-29 | 16:00:00  | 22:00:00 |       2750.00 |      10001 |       1 |          1008 |
    .
    .
    .
    (111 rows)
  3. List all engagements and their associated start dates. Sort the records by date in descending order and by engagement in ascending order.

    +------------+------------------+
    | StartDate  | EngagementNumber |
    +------------+------------------+
    | 2013-03-03 |              131 |
    | 2013-02-26 |              128 |
    | 2013-02-25 |              123 |
    | 2013-02-24 |              122 |
    | 2013-02-24 |              126 |
    | 2013-02-24 |              127 |
    | 2013-02-24 |              129 |
    | 2013-02-23 |              124 |
    | 2013-02-23 |              125 |
    | 2013-02-19 |              112 |
    | 2013-02-19 |              114 |
    | 2013-02-19 |              115 |
    | 2013-02-19 |              119 |
    | 2013-02-18 |              118 |
    | 2013-02-17 |              120 |
    | 2013-02-16 |              116 |
    | 2013-02-16 |              121 |
    | 2013-02-12 |              111 |
    | 2013-02-11 |              109 |
    | 2013-02-11 |              110 |
    .
    .
    .
    (111 rows)

School Scheduling Database

  1. Show me a complete list of all the subjects we offner.

    +--------------------------------------------+
    | SubjectName                                |
    +--------------------------------------------+
    | Financial Accounting Fundamentals I        |
    | Financial Accounting Fundamentals II       |
    | Fundamentals of Managerial Accounting      |
    | Intermediate Accounting                    |
    | Business Tax Accounting                    |
    | Introduction to Business                   |
    | Developing A Feasibility Plan              |
    | Introduction to Entrepreneurship           |
    | Information Technology I                   |
    | Information Technology II                  |
    | Introduction to Art                        |
    | Design                                     |
    | Drawing                                    |
    | Painting                                   |
    | Computer Art                               |
    | Art History                                |
    | Biological Principles                      |
    | General Biology                            |
    | Microbiology                               |
    | Chemistry                                  |
    | Fundamentals of Chemistry                  |
    | Organic Chemistry                          |
    | Microcomputer Applications                 |
    | Information Systems Concepts               |
    | Problem Solving and Structured Programming |
    .
    .
    .
    (56 rows)
  2. What kinds of titles are associated with our faculty?

    +---------------------+
    | Title               |
    +---------------------+
    | Instructor          |
    | Associate Professor |
    | Professor           |
    +---------------------+
    (3 rows)
  3. List the names and phone numbers of all our staff, and sort them by last name and first name.

    +-------------+--------------+----------------+
    | StfLastname | StfFirstName | StfPhoneNumber |
    +-------------+--------------+----------------+
    | Abolrous    | Sam          | 555-2611       |
    | Black       | Alastair     | 555-0039       |
    | Bonnicksen  | Joyce        | 555-2726       |
    | Brehm       | Peter        | 555-2501       |
    | Brown       | Robert       | 555-2491       |
    | Coie        | Caroline     | 555-2306       |
    | DeGrasse    | Kirk         | 555-2311       |
    | Ehrlich     | Katherine    | 555-0399       |
    | Glynn       | Jim          | 555-2531       |
    | Hallmark    | Alaina       | 555-2631       |
    | Hallmark    | Gary         | 555-2676       |
    | Hernandez   | Michael      | 555-2711       |
    | Keyser      | Liz          | 555-2556       |
    | Patterson   | Ann          | 555-2591       |
    | Patterson   | Kathryn      | 555-2651       |
    | Patterson   | Luke         | 555-2316       |
    | Patterson   | Maria        | 555-2291       |
    | Rosales III | Joe          | 555-2281       |
    | Sergienko   | Mariya       | 555-2526       |
    | Smith       | David        | 555-2646       |
    | Smith       | Jeffrey      | 555-2596       |
    | Smith       | Tim          | 555-2536       |
    | Viescas     | Caleb        | 555-0037       |
    | Viescas     | Carol        | 555-2576       |
    .
    .
    .
    (27 rows)

Bowling League Database

  1. List all of the teams in alphabetical order.

    +--------------+
    | TeamName     |
    +--------------+
    | Barracudas   |
    | Dolphins     |
    | Huckleberrys |
    | Manatees     |
    | Marlins      |
    | MintJuleps   |
    | Orcas        |
    | Sharks       |
    | Swordfish    |
    | Terrapins    |
    +--------------+
    (10 rows)
  2. Show me all the bowling score information for each of our members.

    +---------+------------+----------+----------+---------------+---------+
    | MatchID | GameNumber | BowlerID | RawScore | HandiCapScore | WonGame |
    +---------+------------+----------+----------+---------------+---------+
    |       1 |          1 |        1 |      146 |           192 |         |
    |       1 |          1 |        2 |      166 |           205 |        |
    |       1 |          1 |        3 |      140 |           171 |         |
    |       1 |          1 |        4 |      146 |           198 |         |
    |       1 |          1 |        5 |      157 |           203 |        |
    |       1 |          1 |        6 |      160 |           198 |         |
    |       1 |          1 |        7 |      170 |           199 |        |
    |       1 |          1 |        8 |      150 |           202 |        |
    |       1 |          2 |        1 |      146 |           192 |         |
    |       1 |          2 |        2 |      135 |           174 |         |
    |       1 |          2 |        3 |      156 |           187 |        |
    |       1 |          2 |        4 |      143 |           195 |        |
    |       1 |          2 |        5 |      149 |           195 |        |
    |       1 |          2 |        6 |      152 |           190 |        |
    |       1 |          2 |        7 |      158 |           187 |        |
    |       1 |          2 |        8 |      136 |           188 |         |
    |       1 |          3 |        1 |      153 |           199 |        |
    |       1 |          3 |        2 |      177 |           216 |        |
    |       1 |          3 |        3 |      191 |           222 |        |
    |       1 |          3 |        4 |      148 |           200 |        |
    |       1 |          3 |        5 |      139 |           185 |         |
    |       1 |          3 |        6 |      142 |           180 |         |
    |       1 |          3 |        7 |      192 |           221 |         |
    .
    .
    .
    (1344)
  3. Show me a list of bowlers and their addresses, and sort it in alphabeti-cal order.

    +----------------+-----------------+-------------------------+-------------+-------------+-----------+
    | BowlerLastName | BowlerFirstName | BowlerAddress           | BowlerCity  | BowlerState | BowlerZip |
    +----------------+-----------------+-------------------------+-------------+-------------+-----------+
    | Black          | Alastair        | 4726 - 11th Ave. N.E.   | Seattle     | WA          | 98105     |
    | Cunningham     | David           | 4110 Old Redmond Rd.    | Redmond     | WA          | 98052     |
    | Ehrlich        | Zachary         | 507 - 20th Ave. E.      | Seattle     | WA          | 98122     |
    | Fournier       | Barbara         | 67 Willow Drive         | Bothell     | WA          | 98123     |
    | Fournier       | David           | 67 Willow Drive         | Bothell     | WA          | 98123     |
    | Hallmark       | Alaina          | Route 2, Box 203B       | Woodinville | WA          | 98072     |
    | Hallmark       | Bailey          | Route 2, Box 203B       | Woodinville | WA          | 98072     |
    | Hallmark       | Elizabeth       | Route 2, Box 203B       | Woodinville | WA          | 98072     |
    | Hallmark       | Gary            | Route 2, Box 203B       | Woodinville | WA          | 98072     |
    | Hernandez      | Kendra          | 47 Harvard Drive        | Kirkland    | WA          | 98033     |
    | Hernandez      | Michael         | 47 Harvard Drive        | Kirkland    | WA          | 98033     |
    | Kennedy        | Angel           | 2957 W 33rd             | Ballard     | WA          | 98099     |
    | Kennedy        | John            | 2957 W 33rd             | Ballard     | WA          | 98099     |
    | Patterson      | Ann             | 16 Maple Lane           | Auburn      | WA          | 98002     |
    | Patterson      | Kathryn         | 16 Maple Lane           | Auburn      | WA          | 98002     |
    | Patterson      | Megan           | 16 Maple Lane           | Auburn      | WA          | 98002     |
    .
    .
    .
    (32 rows)

Recipes Database

  1. Show me a list of all the ingredients we currently keep track of.

    +-------------------------------+
    | IngredientName                |
    +-------------------------------+
    | Beef                          |
    | Onion                         |
    | Water                         |
    | Guinness Beer                 |
    | Potato                        |
    | Carrot                        |
    | Tomato                        |
    | Jalapeno                      |
    | Garlic                        |
    | Black Pepper (ground)         |
    | Salt                          |
    | Halibut                       |
    | Chicken, Fryer                |
    | Bacon                         |
    | Romaine Lettuce               |
    | Iceberg Lettuce               |
    | Butterhead Lettuce            |
    | Scallop                       |
    | Salmon                        |
    | Vinegar                       |
    | Olive Oil                     |
    | Cucumber                      |
    | Mushrooms                     |
    | Red Wine                      |
    .
    .
    .
    (79 rows)
  2. Show me all the main recipe information, and sort it by the name of the recipe in alphabetical order.

    +----------+-------------------------------------------------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | RecipeID | RecipeTitle                                           | RecipeClassID | Preparation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Notes                                                                                                                                                                                                                                                                                                          |
    +----------+-------------------------------------------------------+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    |       12 | Asparagus                                             |             2 | Wash the asparagus and break off the tough part (if any) at the bottom of the stalks.  Arrange on a steaming rack in a large saucepan.  Dab liberally with pats of butter and sprinkle on the chopped garlic.  Steam until just tender -- no more than 5 minutes for large stalks.  Serve immediately.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | You can chill the cooked asparagus and serve with your favorite dip as an appetizer.                                                                                                                                                                                                                           |
    |       15 | Coupe Colonel                                         |             6 | For each person, place 2 scoops of lemon sorbet in a stemmed glass.  Top with vodka.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | This is a lovely, light, and refreshing dessert.  Use the best sorbet and vodka you can find.  Serve with crisp cookies.                                                                                                                                                                                       |
    (15 rows)