Assignment 3 Linda Zhu
Assignment 3 Linda Zhu
Assignment 3 Linda Zhu
*Submit a single PDF document, with your name on the cover page.
AY 2018/19 – SEM 1
SQL I
5. Given a table named store with 5 fields: store_id, address, city, state, zipcode, why
would the following insert command not work?
1
7. In an SQL statement, which of the following parts states the conditions for row
selection?
A) Select
B) From
C) Where
D) Group By
A) Selects all the fields from the Customer table for each row with a customer labeled
"Best"
B) Selects the "*" field from the Customer table for each row with a customer labeled
"Best"
C) Selects fields with a "*" in them from the Customer table
D) Selects all the fields from the Customer table for each row with a customer labeled
"*"
Select Item_No
from Order_V
where quantity > 10;
Update Product_T
Set Unit_Price = 775
Where Product_ID = 7
2
C) Changes the length of the Unit_Price field to 775
D) Updates the Product_T table to have a unit price of 775
14. The SQL command defines a logical table from one or more tables or views.
A) create table
B) alter table
C) create view
D) create relationship
3
Problem I (12%)
15. Write the SQL commands for creating each of the relations shown below. Specify the
primary key(s) and foreign key(s) (if necessary) constrains for each relation in the
commands. (9%)
4
For each relation (1.5%):
- Create the relation in your workspace using MySQL Workbench, e.g., UA
ID_workspace, using your command (0.5%)
- Copy your command to the submission document (0.5%)
USE xiaoyizhu_workspace;
DESCRIBE Student_T;
6
DESCRIBE Faculty_T;
DESCRIBE Course_T;
DESCRIBE Qualified_T;
DESCRIBE Section_T;
DESCRIBE Registration_T;
- Take a screenshot after displaying the information for the relation’s columns
(using DESCRIBE <tablename>) (0.5%)
7
16. Write the SQL commands for inserting the following data into the COURSE relation.
(3%)
CourseID CoureName
ISM 3113 Syst Analysis
ISM 3112 Syst Design
ISM 4212 Database
ISM 4930 Network
8
Problem 2 (6%)
17. Based on the classicmodels on our MySQL Server, what SQL queries would you use to
retrieve the following information?
I. Retrieve all values from the customerName and city attributes in the customers
table (1%)
II. Retrieve all records in the orders table (1%)
III. Retrieve all the orders that have been cancelled (1%)
IV. Retrieve all the orders where the corresponding customerNumber is greater than
100 (1%)
V. Retrieve all the employees whose jobTitle is not “Sales Rep” (1%)
VI. Retrieve the list of job titles for employees (1%)
II.
9
III.
IV.
V.
1
0
VI.
1
1