0% found this document useful (0 votes)
23 views2 pages

Homework 1

This document provides instructions for homework assignments involving creating and altering relation schemas in MySQL. Students are asked to write CREATE and ALTER statements for relation schemas describing computer components and World War II capital ships. The schemas must have correct SQL syntax and formatting. Copying answers from others is considered cheating.

Uploaded by

aaa zzz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Homework 1

This document provides instructions for homework assignments involving creating and altering relation schemas in MySQL. Students are asked to write CREATE and ALTER statements for relation schemas describing computer components and World War II capital ships. The schemas must have correct SQL syntax and formatting. Copying answers from others is considered cheating.

Uploaded by

aaa zzz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COSC 4820

Database Systems, Spring 2023


Homework 1, Relation Schema

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.

Question 1: [30 points]


A database has four relations whose schema are

Product(maker, model, type)


PC(model, speed, ram, hd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type, price)

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

Classes(class, type, country, numGuns, bore, displacement)


Ships(name, class, launched)
Battles(name, data)
Outcomes(ship, battle, result)

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

You might also like