Homework 1
Homework 1
For this assignment you will be writing MySQL (SQL) statements. I expect that your
answers will actually be READABLE. Do not just start at the left margin and type until
you are done. Format your answers so that they are easy to read/grade. AND all the MySql
(SQL) statements MUST have the correct syntax, including the statement end.
Using the online documentation for MySQL is NOT a problem. Talking to your classmates
is okay. Copying someone else’s answers (online or your friend’s) is CHEATING. I expect
complete academic honesty in this course.
We assume that model numbers are unique over all manufacturers and product types.
Processor speed will be in gigahertz, RAM in megabytes, laptop screen size in inches.
For the printers, color is true or false, and type will be laser or ink-jet.
Give CREATE or ALTER statements for the schema for the computer component rela-
tions.
(a) [5 points] A suitable schema for relation Product.
(b) [5 points] A suitable schema for relation PC.
(c) [5 points] A suitable schema for relation Laptop.
(d) [5 points] A suitable schema for relation Printer.
(e) [5 points] An alteration of your Printer schema from (d) to delete the attribute
color.
(f) [5 points] An alteration of your Laptop schema from (c) to add the attribute od
(optical-disk type, e.g., cd or dvd). Let the default value for this attribute be ‘none’
if the laptop does not have an optical-disk.
Question 2: [30 points]
Another database, capital ships in World War II, also has four relations whose schema
are
Ships are built in “classes” from the same design, and the class is usually named for
the first ship in that class. The types (for now) are limited to battlecruiser (bc) and
battleship (bb). Any others that are added will also have 2 character types. Bore is the
diameter of the main guns in inches, and displacement is the weight in tons. For the
Outcomes of the battles, the result is one of ‘sunk’, ‘damaged’, or ‘ok’.
Give CREATE or ALTER statements for the schema for the World War II ship relations.
(a) [5 points] A suitable schema for relation Classes.
(b) [5 points] A suitable schema for relation Ships.
(c) [5 points] A suitable schema for relation Battles.
(d) [5 points] A suitable schema for relation Outcomes.
(e) [5 points] An alteration of your Classes schema from (a) to delete the attribute
bore.
(f) [5 points] An alteration of your Ships schema from (b) to include the attribute
yard giving the shipyard where the ship was built.
Page 2