Sunteți pe pagina 1din 2

Assignment Chapter 3 (Database System)

Student Name:
Group:
Deadline: --/--/2020
Submit to: Lec. Mr. Sun Sophorn

I. Review Questions
1. Describe the process of creating a table in SQL and the different data types you can use
for fields.
2. What is the purpose of the WHERE clause in SQL? Which comparison operators can you
use in a WHERE clause?
3. How do you write a compound condition in an SQL query? When is a compound condition
true?
4. What is a computed field? How can you use one in an SQL query? How do you assign a
name to a computed field?
5. How do you use the LIKE and IN operators in an SQL query?
6. How do you sort data in SQL? When there is more than one sort key, how do you indicate
which one is the major sort key? How do you sort data in descending order?
7. What are the SQL built-in functions? How do you use them in an SQL query?
8. What is a subquery? When is a subquery executed?
9. How do you group data in SQL? When you group data in SQL, are there any restrictions on
the items that you can include in the SELECT clause? Explain.
10. How do you join tables in SQL?
11. How do you take the union of two tables in SQL? What criteria must the tables meet to
make a union possible?
12. Describe the three update commands in SQL.
13. How do you save the results of an SQL query as a table?

II. Premiere Products Exercises


In the following exercises, you will use the data in the Premiere Products database in Chapter 2.
(If you use a computer to complete these exercises, use a copy of the original Premiere
Products database so you will still have the original data when you complete Chapter 4.) In each
step, use SQL to obtain the desired results. You can use a DBMS to complete the exercises using
a computer, or you can simply write the SQL command to complete each step.
1. List the number and name of all customers.
2. List the complete Part table.
3. List the number and name of every customer represented by sales rep 35.
4. List the number and name of all customers that are represented by sales rep 35 and that
have credit limits of $10,000.
5. List the number and name of all customers that are represented by sales rep 35 or that
have credit limits of $10,000.
6. For each order, list the order number, order date, number of the customer that placed the
order, and name of the customer that placed the order.
7. List the number and name of all customers represented by Juan Perez.
8. How many orders were placed on 10/20/2013?
9. Find the total of the balances for all customers represented by sales rep 35.

sophorn26sun.blogspot.com Page 1 of 2
10. Give the part number, description, and on-hand value (OnHand * Price) for each part in
item class HW.
11. List all columns and all rows in the Part table. Sort the results by part description.
12. List all columns and all rows in the Part table. Sort the results by part number within item
class.
13. List the item class and the sum of the number of units on hand. Group the results by item
class.
14. Create a new table named SportingGoods to contain the columns PartNum, Description,
OnHand, Warehouse, and Price for all rows in which the item class is SG.
15. In the SportingGoods table, change the description of part BV06 to “Fitness Gym.”
16. In the SportingGoods table, delete every row in which the price is greater than $1,000.
III. Henry Books Case
Ray Henry knows the importance of the SQL language in database management. He realizes
that he can use SQL to perform the same functions that you performed with queries in Chapter
2. In each of the following steps, use SQL to obtain the desired results using the data shown in
Chapter 1. (If you use a computer to complete these exercises, use a copy of the original Henry
Books database so you will still have the original data when you complete Chapter 4.) You can
use a DBMS to complete the exercises using a computer, or you can simply write the SQL
command to complete each step.
1. List the name of each publisher that’s not located in New York.
2. List the title of each book published by Penguin USA.
3. List the title of each book that has the type MYS.
4. List the title of each book that has the type SFI and that is in paperback.
5. List the title of each book that has the type PSY or whose publisher code is JP.
6. List the title of each book that has the type CMP, HIS, or SCI.
7. How many books have a publisher code of ST or VB?
8. List the title of each book written by Dick Francis.
9. List the title of each book that has the type FIC and that was written by John Steinbeck.
10. For each book with coauthors, list the title, publisher code, type, and author names (in the
order listed on the cover).
11. How many book copies have a price that is greater than $20 but less than $25?
12. List the branch number, copy number, quality, and price for each copy of The Stranger.
13. List the branch name, copy number, quality, and price for each copy of Electric Light.
14. For each book copy with a price greater than $25, list the book’s title, quality, and price.
15. For each book copy available at the Henry on the Hill branch whose quality is excellent,
list the book’s title and author names (in the order listed on the cover).
16. Create a new table named FictionCopies using the data in the BookCode, Title,
BranchNum, CopyNum, Quality, and Price columns for those books that have the type FIC.
17. Ray Henry is considering increasing the price of all copies of fiction books whose quality is
excellent by 10%. To determine the new prices, list the book code, title, and increased
price of every book in the FictionCopies table. (Your computed column should determine
110% of the current price, which is 100% plus a 10% increase.)
18. Use an update query to change the price of each book in the FictionCopies table with a
current price of $14.00 to $14.50.
19. Use a delete query to delete all books in the FictionCopies table whose quality is poor.

sophorn26sun.blogspot.com Page 2 of 2

S-ar putea să vă placă și