Question

In: Computer Science

Assignment Description: In this assignment, a script file should be created to contain a set a...

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:

  1. 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.
  2. Create a view named Allen. It consists of the customer_id, customer_name, customer_phone, title, and artist of each print ordered.
  3. 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.
  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.
  5. Create the following indexes. Use the indicated index name.
    1. Create an index named customer_id on the customer_id field in the customers table.
    2. Create an index named name on the customer_name field in the customers table.
    3. Create an index named shipped on the customer_id and ship_date in the orders table.
  6. Drop the name index.
  7. Specify the integrity constraint that the unit_price of any print must be more than $35.
  8. 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.

  1. Add to the items table a new character field named type that is one character in length.

  1. Change the type field in the items table to M for the print titled Skies Above.
  2. Change the length of the artist field in the items table to 30.
  3. What command would you use to delete the orders table from the prints database? (Do not delete the orders table.)


HERE IS DATABASE CREATED IN ASSIGNMENT 2:

USE PrettyPrints;

SELECT customer_name, customer_add, customer_city, customer_state, customer_zip FROM customers;
SELECT customer_name, customer_phone FROM customers WHERE customer_state = 'GA';
SELECT customer_name, customer_zip FROM customers WHERE customer_state = 'NC' OR customer_state = 'SC';
SELECT title, artist, order_date, ship_date FROM items,orders,orderline WHERE orders.order_id = orderline.order_id AND items.item_id = orderline.item_id;
SELECT * FROM items ORDER BY unit_price ASC;
SELECT * FROM items WHERE unit_price > 100.00;
SELECT * FROM items WHERE on_hand > 300;
SELECT title, unit_price, unit_price * 2 AS retail_price FROM items;
SELECT title, order_qty FROM items,orderline WHERE items.item_id = orderline.item_id;
SELECT title FROM items WHERE unit_price BETWEEN 40 AND 100;
Select customer_name, title, artist, sum (order_qty) from customers left outer join orders on customers.customer_id = orders.customer_id join orderline on orders.order_id = orderline.order_id join items on orderline.item_id = items.item_id group by items.artist order by items.artist;

SELECT c.customer_name, c.customer_phone FROM customers c LEFT OUTER JOIN orders o ON c.customer_id = o.order_id WHERE YEAR(o.ORDER_DATE) = '2014';

SELECT customer_name, sum(unit_price * 2) AS total_revenue FROM customers join orders on customers.customer_id = orders.customer_id join orderline on orders.order_id = orderline.order_id join items on orderline.item_id = items.item_id group by customer_name;
SELECT customer_state, COUNT(DISTINCT customer_name) AS number_of_customers FROM customers GROUP BY customer_state;

Solutions

Expert Solution


Related Solutions

Write a bash script file that tests each file entry in the current directory. It should...
Write a bash script file that tests each file entry in the current directory. It should determine if it is a file or directory. If it is a file, it will determine if it is readable or not. If it is readable, it will display only the first 4 lines to the terminal in sorted order (just sort the first 4 lines). If it is a directory, it should display the contents of that directory (the files and subdirectories). NOTE:...
For this assignment, you will use the provided database in the Unit 5 script file. You...
For this assignment, you will use the provided database in the Unit 5 script file. You will add statements to this file to query the database tables. For your reference, below is a screenshot of the enhanced entity relationship diagram (ERD) as a reference when you write your queries. With the data types listed in the diagram, this will help you identify the types of operators that you can use for particular queries. Use paiza.io for MySQL to execute and...
This should be done in JavaScript. The HTML file should only contain an empty main tag....
This should be done in JavaScript. The HTML file should only contain an empty main tag. All other HTML on the page should be created with JavaScript. The JavaScript file should be a separate file.   Make an empty HTML file, put an empty main tag inside the body. In your JavaScript, use querySelector to get a reference to the main tag and save it in a variable named main. Look up three good jokes and store them as separate variables...
Write a C++ program to create a text file. Your file should contain the following text:...
Write a C++ program to create a text file. Your file should contain the following text: Batch files are text files created by programmer. The file is written in notepad. Creating a text file and writing to it by using fstream: to write to a file, you need to open thew file as write mode. To do so, include a header filr to your program. Create an object of type fsrteam. Open the file as write mode. Reading from a...
Although there are a variety of purchase requisition formats, every requisition should contain the description of...
Although there are a variety of purchase requisition formats, every requisition should contain the description of the material or service, the quantity and date required, the estimated unit cost, the operating account to be charged, plus which of the following items? a. Date of the requisition b. Date required c. Authorized signature d. All of the above e. Items b) and c)
how to create a script file on puTTy script pp1.txt
how to create a script file on puTTy script pp1.txt
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
Develop a matlab script file to calculate the practical single phase transformer parameters. The program should...
Develop a matlab script file to calculate the practical single phase transformer parameters. The program should ask the user to provide the following individually: S_rated V1_rated V2_rated With secondary shorted P1 V1 With primary open P2 I2 The program should calculate Req Xeq Zeq Gc Ym Bm Make sure your code will pronmpt a message like: “Enter the real power at the primary winding when the secondary winding is shorted, P1=). Do the same for all parameters S, V1_rated, V2_rated,...
Create an app that stores a set of names. The UI should contain a EditText widget...
Create an app that stores a set of names. The UI should contain a EditText widget and two Buttons (one for adding a name and one for editing a name).   When the app starts up, the first name of the set is used to initialize the EditText widget. The app uses ViewPager so that the user can swipe left to visit the previous name in the set, or swipe right to visit the next name in the set, similar to...
/* WordList source file * * *   This file will contain the function definitions you will...
/* WordList source file * * *   This file will contain the function definitions you will implement. *   The function signitures may NOT be changed. You may create your own *   helper functions and include them in this file. * *   In addition to the specific instructions for each function, no function *   should cause any memory leaks or alias m_list in any way that would result *   in undefined behavior. * *   Topics: Multilevel Pointers, Dynamic Allocation, Classes *...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT