Activity: DB design, integrity constraints, and SQL

(no submission)
Purpose:

You may make a copy of a worksheet and complete this activity, or simply type your answers in any text editor.

You may work alone or with 3-4 other students in this course (max size=5).


Consider the Santa_Workshop database. Refer to the Santa's workshop database scenario.

image showing Santa workshop ER

Complete/Answer the following questions

  1. Convert the Santa’s workshop E-R diagram (above) into schema statements. Identify primary keys and foreign keys.
  2. If toy_id is a key for the Toy relation, could it be a key for the Built_in relation?

Write SQL to solve the following problems

  1. Create all tables represented by the schema statements in question 1
  2. Find the badges and names of all elves who work in a workshop named "NorthStar"
  3. Find the badges and names of all elves who work at the "NorthStar" or "EastStar" workshops
  4. Find the number of elves each supervisor supervises. Display the supervisors’ badges along with the number of elves.
  5. Consider all elves who work in the "NorthStar" workshop. Find the badges of their supervisors.
  6. List the badges of all supervisors who supervise at least 3 elves.
  7. Find the elves who work in the same workshop as their supervisors. Display the elves' badges and their supervisors' badges.
  8. Find the information of all toys built in "NorthStar" or "EastStar" workshops
  9. Find the information of all toys built in "NorthStar" and "EastStar" workshops
  10. Find the information of all toys built in "NorthStar" but not in "EastStar" workshops
  11. Consider all elves who work in the "NorthStar" workshop. Find their supervisors' badges and names
  12. Find the number of evaluations each rater has rated. List the names of the raters along with the number evaluations.

Copyright © 2024 Upsorn Praphamontripong

Released under the Creative Commons License CC-BY-NC-SA 4.0 license.

Last updated 2024-02-25 16:52