**PLEASE INCLUDE SCREENSHOTS**** Pretty Prints III Assignment Description: In th
ID: 3705798 • Letter: #
Question
**PLEASE INCLUDE SCREENSHOTS****
Pretty Prints III
Assignment Description: In this assignment, a script file should be created to contain a set a SQL statements for the Pretty Prints Company to better manage their business. Use the database created for Pretty Prints in Assignment 2. Include the SQL statements to satisfy the following queries.
The following queries should be included in the script:
Create a view named Under_100. It consists of the item_id, title, artist, unit_price and order_qty for every print with a unit_price under 100 dollars.
Create a view named Allen. It consists of the customer_id, customer_name, customer_phone, title, and artist of each print ordered.
Create a view named orders. It consists of the item_id, title, artist, unit_price and order_qty for every print ordered in the range of 2014-01-01 and 2014-02-28.
Create a view named zip_27. It consists of the customer_name, customer_phone, title, artist and date_shipped of each print ordered by a customer whose zip code begins with 27.
Create the following indexes. Use the indicated index name.
Create an index named customer_id on the customer_id field in the customers table.
Create an index named name on the customer_name field in the customers table.
Create an index named shipped on the customer_id and ship_date in the orders table.
Drop the name index.
Specify the integrity constraint that the unit_price of any print must be more than $35.
Create the following foreign keys within the prints database.
a. customer_id is a foreign key in the orders table.
b. Item_id is a foreign key in the orderline table.
Add to the items table a new character field named type that is one character in length.
Change the type field in the items table to M for the print titled Skies Above.
Change the length of the artist field in the items table to 30.
What command would you use to delete the orders table from the prints database? (Do not delete the orders table.)
REQUIREMENTS:
Each student must work independently on this assignment. No group work is allowed.
Submit completed work into Canvas.
Take a screenshot of the submission verification in the event you need proof of submission.
Explanation / Answer
Hi Dear,
Since you have not posted data for the table. I have wrriten query according to question.
Create a view named Under_100. It consists of the item_id, title, artist, unit_price and order_qty for every print with a unit_price under 100 dollars.
CREATE VIEW Under_100 AS
SELECT items.item_id, title, artist, unit_price, order_qty
FROM items, orderline
WHERE items.item_id = orderline.item_id
AND unit_price < 100.00;
Create a view named Allen. It consists of the customer_id, customer_name, customer_phone, title, and artist of each print ordered.
CREATE VIEW Allen AS
SELECT customers.customer_id, customer_name, customer_phone, title, artist
FROM customers, items, orderline, orders
WHERE customers.customer_id = orders.customer_id
AND orders.order_id = orderline.order_id
AND orderline.item_id = items.item_id;
4. Create a view named zip_27. It consists of the customer_name, customer_phone, title, artist
and date_shipped of each print ordered by a customer whose zip code begins with 27. */
CREATE VIEW zip_27 AS
SELECT customer_name, customer_phone, title, artist, ship_date
FROM customers, items, orders, orderline
WHERE customers.customer_id = orders.customer_id
AND orders.order_id = orderline.order_id
AND orderline.item_id = items.item_id
AND customer_zip LIKE '27%';
5. Create the following indexes. Use the indicated index name.
DEBUG COMMAND: SHOW INDEX FROM insert_name_of_column;
CREATE INDEX customer_id
ON customers (customer_id);
CREATE INDEX name
ON customers (customer_name);
CREATE INDEX shipped
ON orders (customer_id , ship_date);
Drop the name index.
DROP INDEX name ON customers;
Specify the integrity constraint that the unit_price
of any print must be more than $35.
ALTER TABLE items
ADD CHECK (unit_price > 35.00);
. Ensure that the following are foreign keys
(that is, specify referential integrity) within the prints database.
/* A - customer_id is a foreign key in the orders table. */
ALTER TABLE items;
/* B - Item_id is a foreign key in the orderline table. */
ALTER TABLE items;
Add to the items table a new character field named type that is one character in length.
ALTER TABLE items
ADD TYPE CHARACTER(1);
/* . Change the type field in the items table to M for the print titled Skies Above. */
UPDATE items
SET TYPE='M'
WHERE title = 'Skies Above';
/* Change the length of the artist field in the items table to 30. */
ALTER TABLE items
CHANGE COLUMN artist TO CHARACTER(30);
What command would you use to delete the orders table from the prints database?
(Do not delete the orders table.)
DROP TABLE orders;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.