Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You must use Oracle for this part. Please show the complete question, query used, and print the query results. Use the TAL Distributors database only.

You must use Oracle for this part. Please show the complete question, query used, and print the query results. Use the TAL Distributors database only.

Only answer odd numbered questions: 1,3,5,7,9,11

image text in transcribedimage text in transcribedimage text in transcribed

TAL Distributor:

DROP TABLE REP; CREATE TABLE REP( REP_NUM CHAR(2) PRIMARY KEY, LAST_NAME CHAR(15) NOT NULL, FIRST_NAME CHAR(15) NOT NULL, STREET CHAR(15), CITY CHAR(15), STATE CHAR(2), POSTAL_CODE CHAR(5), COMMISSION DECIMAL(7,2), RATE DECIMAL(3,2));

INSERT INTO REP values(15,'Campos','Rafael','724 Vinca Dr.','Grove','CA',90092,23457.50,0.06);

INSERT INTO REP values(30,'Gradey','Megan','632 Liacris St.','Fullton','CA',90085,41317.00,0.08);

INSERT INTO REP values(45,'Tian','Hui','1785 Tyler Ave.','Northfield', 'CA', 90098, 27789.25,0.06);

INSERT INTO REP values(60,'Sefton','Jauot','267 Oakley St.','Congaree','CA',90097,0.00,0.06);

DROP TABLE CUSTOMER; CREATE TABLE CUSTOMER( CUSTOMER_NUM CHAR(3) PRIMARY KEY, CUSTOMER_NAME CHAR(35) NOT NULL, STREET CHAR(20), CITY CHAR(15), STATE CHAR(2), POSTAL_CODE CHAR(5), BALANCE DECIMAL(8,2), CREDIT_LIMIT DECIMAL(8,2), REP_NUM CHAR(2));

INSERT INTO CUSTOMER values (126,'Toys Galore','28 Laketon St.','Fullton','CA',90085,1210.25,7500.00,15); INSERT INTO CUSTOMER values(260,'Brookings Direct','452 Columbus Dr.','Grove','CA',90092,575.00,10000.00,30);

INSERT INTO CUSTOMER values(334,'The Everything Shop','342 Magee St.','Congaree','CA',90097,2345.75,7500.00,45);

INSERT INTO CUSTOMER values(386,'Johnson"s Department Store','124 Main St.','Northfield','CA',90098,879.25,7500.00,30);

INSERT INTO CUSTOMER values(440,'Grove Historical Museum Store','3456 Central Ave.','Fullton','CA',90085,345.00,5000.00,45); INSERT INTO CUSTOMER values(502,'Cards and More','167 Hale St.','Mesa','CA',90104,5025.75,5000.00,15);

INSERT INTO CUSTOMER values(586,'Almondton General Store','3345 Devon Ave.','Almondton','CA',90125,3456.75,15000.00,45);

INSERT INTO CUSTOMER values(665,'Cricket Gift Shop','372 Oxford St.','Grove','CA',90092,678.90,7500.00,30);

INSERT INTO CUSTOMER values(713,'Cress Store','12 Rising Sun Ave.','Congaree','CA',90097,4234.60,10000.00,15);

INSERT INTO CUSTOMER values(796,'Unique Gifts','786 Passmore St.','Northfield','CA',90098,124.75,7500.00,45);

INSERT INTO CUSTOMER values(824,'Kline"s','945 Gilham St,','Mesa','CA',90104,2475.99,15000.00,30);

INSERT INTO CUSTOMER values(893,'All Season Gifts','382 Wildwood Ave.','Fullton','CA',90085,935.75,7500.00,15);

DROP TABLE ORDERS; CREATE TABLE ORDERS( ORDER_NUM CHAR(5) PRIMARY KEY, ORDER_DATE DATE, CUSTOMER_NUM CHAR(3));

INSERT INTO ORDERS values(51608,'2015-10-12',126);

INSERT INTO ORDERS values(51610,'2015-10-12',334);

INSERT INTO ORDERS values(51613,'2015-10-13',386);

INSERT INTO ORDERS values(51614,'2015-10-13',260);

INSERT INTO ORDERS values(51617,'2015-10-15',586);

INSERT INTO ORDERS values(51619,'2015-10-15',126);

INSERT INTO ORDERS values(51623,'2015-10-15',586);

INSERT INTO ORDERS values(51625,'2015-10-16',796);

DROP TABLE ITEM; CREATE TABLE ITEM( ITEM_NUM CHAR(4) PRIMARY KEY, DESCRIPTION CHAR(30), ON_HAND DECIMAL(4,0), CATEGORY CHAR(3), STOREHOUSE CHAR(1), PRICE DECIMAL(6,2)); INSERT INTO ITEM values ('AH74','Patience',9.00,'GME','3',22.99); INSERT INTO ITEM values ('BR23','Skittles',21.00,'GME','2',29.99); INSERT INTO ITEM values ('CD33','Wood Block Set (48 piece)',36.00,'TOY','1',89.49); INSERT INTO ITEM values ('DL51','Classic Railway Set',12.00,'TOY','1',107.95); INSERT INTO ITEM values ('DR67','Giant Star Brain Teaser',24.00,'PZL','2',31.95); INSERT INTO ITEM values ('DW23','Mancala',40.00,'GME','3',50.00); INSERT INTO ITEM values ('FD11','Rocking Horse',8.00,'TOY','3',124.95); INSERT INTO ITEM values ('FH24','Puzzle Gift Set',65.00,'PZL','1',38.95); INSERT INTO ITEM values ('KA12','Cribbage Set',56.00,'GME','3',75.00); INSERT INTO ITEM values ('KD34','Pentominous Brain Teaser',60.00,'PZL','2',14.95); INSERT INTO ITEM values ('KL78','Pick Up Sticks',110.00,'GME','1',10.95); INSERT INTO ITEM values ('MT03','Zauberkasten Brain Teaser',45.00,'PZL','1',45.79); INSERT INTO ITEM values ('NL89','Wood Block Set (62 piece)',32.00,'TOY','3',119.75); INSERT INTO ITEM values ('TR40','Tic Tac Toe',75.00,'GME','2',13.99); INSERT INTO ITEM values ('TW35','Fire Engine',30.00,'TOY','2',118.95);

DROP TABLE ORDER_LINE; CREATE TABLE ORDER_LINE( ORDER_NUM CHAR(5), ITEM_NUM CHAR(4), NUM_ORDERED DECIMAL(3,0), QUOTED_PRICE DECIMAL(6,2), PRIMARY KEY (ORDER_NUM, ITEM_NUM));

INSERT INTO ORDER_LINE values(51608,'CD33',5.00,86.99); INSERT INTO ORDER_LINE values(51610,'KL78',25.00,10.95); INSERT INTO ORDER_LINE values(51610,'TR40',10.00,13.99); INSERT INTO ORDER_LINE values(51613,'DL51',5.00,104.95); INSERT INTO ORDER_LINE values(51614,'FD11',1.00,124.95); INSERT INTO ORDER_LINE values(51617,'NL89',4.00,115.99); INSERT INTO ORDER_LINE values(51617,'TW35',3.00,116.95); INSERT INTO ORDER_LINE values(51619,'FD11',2.00,121.95); INSERT INTO ORDER_LINE values(51623,'DR67',5.00,29.95); INSERT INTO ORDER_LINE values(51623,'FH24',12.00,36.95); INSERT INTO ORDER_LINE values(51623,'KD34',10.00,13.10); INSERT INTO ORDER_LINE values(51625,'MT03',8.00,45.79);

DROP TABLE SALESREP; CREATE TABLE SALES_REP( REP_NUM char(2), LAST_NAME varchar(15), FIRST_NAME char(15), STREET char(15), CITY char(15), STATE char(2), POSTAL_CODE char(5), COMMISSION decimal(11,2), RATE decimal(11,2), PRIMARY KEY (REP_NUM) );

Exercises TAL Distributors Use SQL to make the following changes to the TAL Distributors database (see Figure 1-2 in Chapter 1). After each change, execute an appropriate query to show that the change was made correctly. If directed to do so by your instructor, use the information provided with the Chapter 3 Exercises to print your output or save it to a document. For any exercises that use commands not supported by your version of SQL, write the command to accomplish the task. 1. Create a view named MAJOR_CUSTOMER. It consists of the customer number, name, bal- ance, credit limit, and rep number for every customer whose credit limit is $10,000 or less. a. Write and execute the CREATE VIEW command to create the MAJOR_CUSTOMER view. b. Write and execute the command to retrieve the customer number and name of each customer in the MAJOR_CUSTOMER view with a balance that exceeds the credit limit. c. Write and execute the query that the DBMS actually executes. d. Does updating the database through this view create any problems? If so, what are they? If not, why not? 2. Create a view named ITEM_ORDER. It consists of the item number, description, price, order number, order date, number ordered, and quoted price for all order lines currently on file. C. a. Write and execute the CREATE VIEW command to create the ITEM_ORDER view. b. Write and execute the command to retrieve the item number, description, order num- ber, and quoted price for all orders in the ITEM_ORDER view for items with quoted prices that exceed $100. Write and execute the query that the DBMS actually executes. d. Does updating the database through this view create any problems? If so, what are they? If not, why not? 3. Create a view named ORDER_TOTAL. It consists of the order number and order total for each order currently on file. (The order total is the sum of the number of units ordered multiplied by the quoted price on each order line for each order.) Sort the rows by order number. Use TOTAL_AMOUNT as the name for the order total. a. Write and execute the CREATE VIEW command to create the ORDER_TOTAL view. b. Write and execute the command to retrieve the order number and order total for only those orders totaling more than $500. C. Write and execute the query that the DBMS actually executes. d. Does updating the database through this view create any problems? If so, what are they? If not, why not? 4. Write, but do not execute, the commands to grant the following privileges: a. User Ashton must be able to retrieve data from the ITEM table. b. Users Kelly and Morgan must be able to add new orders and order lines. User James must be able to change the price for all items. d. User Danielson must be able to delete customers. All users must be able to retrieve each customer's number, name, street, city, state, and postal code. f. User Perez must be able to create an index on the ORDERS table. g. User Washington must be able to change the structure of the ITEM table. h. User Grinstead must have all privileges on the ORDERS table. 5. Write, but do not execute, the command to revoke the privilege given to user Ashton in Exercise 4a. 6. Perform the following tasks: a. Create an index named ITEM_INDEX1 on the ITEM_NUM column in the ORDER_LINE table. b. Create an index named ITEM_INDEX2 on the CATEGORY column in the ITEM table. Create an index named ITEM_INDEX3 on the CATEGORY and STOREHOUSE columns in the ITEM table. d. Create an index named ITEM_INDEX4 on the CATEGORY and STOREHOUSE columns in the ITEM table. List categories in descending order. 7. Delete the index named ITEM_INDEX3. 8. Write the commands to obtain the following information from the system catalog. Do not C. e. c. a. List every table that you own. b. List every column in the ITEM table and its associated data type. 9. Add the ORDER_NUM column as a foreign key in the ORDER_LINE table. 10. Ensure that the only legal values for the CREDIT_LIMIT column are 5000, 7500, 10000, and 15000. 11. Toys Galore currently has a credit limit of $7,500. Because Toys Galore has an excellent credit rating, TAL Distributors is increasing the company's credit limit to $10,000. If you run the SQL query in Exercise 1 after the credit limit has been increased, would Toys Galore still be included in the view? Why or why not

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

U11 Informing Industry: Publicizing Contract Actions 317

Answered: 1 week ago