Practice Assignment Writing SQL Queries Bookorama Db
Total Page:16
File Type:pdf, Size:1020Kb
Practice assignment – Writing SQL queries – Bookorama db
For each of the following, write the query that will accomplish the assigned task. Items listed as DDL are schemaupdates and DDM are data manipulation. Use the Chapter 6 material as reference. The following website will also give you some reference for the MySQL specific syntax. http://dev.mysql.com/doc/refman/5.1/en/tutorial.html.
Save your query in a text document and put on the drop box for review on Thursday. When you build your query, some will be single statement queries and some will require more than one query statement.
DDM Queries – Basic
1. Write a query that will insert a new row into the Customer table. (Make yourself a customer). 2. Write a query that will display a list of all Books that cost less than $30.00. 3. Write a query that will display a list of all Books that have a Review. 4. Write a query that will display a list of all Books and for those that have a review, list the review. 5. Write a query to insert a new Order. (Orders consist of an Order row and one or more Order_Items.) Choose an existing customer and book. 6. Write a query to display all Books in ascending order by price. 7. Write a query to display all of the information about an order. This will include the customer, books, price, etc. Do not include any of the key fields in your display.
DDL Queries
1. Write a query that will insert a new table, onlineCustomer. This table is a subtype of the customer table and will contain the e-mail address (text 50), a shipping address, and last update date. You should set the customerId as the primary key and should have an index built on the e-mail address. E-mail id may not be null, but the shipping address may be. It should have a constraint that requires a row in the customer table for every row in the onlineCustomer table. 2. Write a query that will put two new customers in the Customer table and also into the onlineCustomer table.
DDM Queries – More Advanced 1. Write a query that will return the highest price of all of the Books. 2. Write a query that returns the sum of the prices of all of the Books.