Question
/* ################### START CREATE AND POPULATE DATABASE ########################## */ DROP DATABASE IF EXISTS mycustomer; CREATE DATABASE mycustomer; USE mycustomer; CREATE TABLE customer( cid varchar(4), cname
/* ################### START CREATE AND POPULATE DATABASE ########################## */ DROP DATABASE IF EXISTS mycustomer;
CREATE DATABASE mycustomer;
USE mycustomer;
CREATE TABLE customer( cid varchar(4), cname varchar(20), street varchar(20), city varchar(20), country varchar(20), phone varchar(12),
PRIMARY KEY(cid) );
CREATE TABLE custorder( oid varchar(4), cid varchar(4), orderdate date, shippingdate date,
PRIMARY KEY(oid), FOREIGN KEY(cid) REFERENCES customer(cid) );
CREATE TABLE itemorder( oid varchar(4), iid varchar(4), quantity int, totalprice decimal(9,2),
PRIMARY KEY(oid, iid), FOREIGN KEY(oid) REFERENCES custorder(oid) );
INSERT INTO customer VALUES ('C223','COMPAQ', '3 Barbados Ave', 'Bridgetown','Barbados','809-956-2345'); INSERT INTO customer VALUES ('C224','IBM', '14 Ruthven Rd', 'Kingston','Jamaica','876-927-2654'); INSERT INTO customer VALUES ('C225','IBM', '24 Hart St', 'Port-au-Prince','Trinidad','309-913-2345'); INSERT INTO customer VALUES ('C226','GATEWAY', '30 Austin Ave', 'Kingston','Jamaica','876-956-2458'); INSERT INTO customer VALUES ('C227','IBM', '5 Seville Rd', 'Bridgetown','Barbados','809-756-1345'); INSERT INTO customer VALUES ('C228','GATEWAY', '3 Kings Way', 'Port-au-Prince','Trinidad','309-756-2375');
INSERT INTO custorder VALUES ('O010','C223','2020-09-24','2020-09-26'); INSERT INTO custorder VALUES ('O011','C227','2020-09-15','2020-09-20'); INSERT INTO custorder (oid, cid, orderdate) VALUES ('O012','C224','2021-01-16'); INSERT INTO custorder VALUES ('O013','C225','2020-07-15','2020-07-20'); INSERT INTO custorder (oid, cid, orderdate) VALUES ('O014','C224','2021-02-16');
INSERT INTO itemorder VALUES('O010','i110',10, 600000.00); INSERT INTO itemorder VALUES('O010','i111',5, 300000.00); INSERT INTO itemorder VALUES('O011','i110',8, 540000.00); INSERT INTO itemorder VALUES('O012','i113',20, 1000000.00); INSERT INTO itemorder VALUES('O012','i111',6, 360000.00); INSERT INTO itemorder VALUES('O012','i114',6, 600000.00); INSERT INTO itemorder VALUES('O013','i114',9, 800000.00);
/* ################### END CREATE AND POPULATE DATABASE ########################## */
Question 7
Find the order that has the greatest total cost.
Question 8
Find the order where the cost is greater that the average cost,
Question 9
Double the quantity of item# i111 on order #O012 (assume that the unit cost does not vary).
Question 10
Assume that the shipping date of those orders being sent to customers in Barbados were delayed by 5 days. Depict this in the database.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started