Question
1. Copy and paste the following MySQL code (in a command line or onpaiza.io). CREATE DATABASE IF NOT EXISTS Supply; USE Supply; CREATE TABLE Customer(
1. Copy and paste the following MySQL code (in a command line or onpaiza.io).
CREATE DATABASE IF NOT EXISTS Supply;
USE Supply;
CREATE TABLE Customer(
CustomerID INT,
CustomerName VARCHAR(128),
Country VARCHAR(128),
PhoneNumber CHAR(16),
Email VARCHAR(128),
PRIMARY KEY(CustomerID)
);
CREATE TABLE CustOrder(
OrderID INT,
CustomerID INT,
TransportFee FLOAT,
OrderYear INT,
PRIMARY KEY(OrderID),
FOREIGN KEY(CustomerID) REFERENCES Customer(CustomerID)
);
CREATE TABLE Supplier(
SupplierID INT,
SupplierName VARCHAR(128),
Country VARCHAR(128),
PhoneNumber CHAR(16),
Email VARCHAR(128),
YearFounded INT,
PRIMARY KEY(SupplierID)
);
CREATE TABLE Product(
ProductID INT,
SupplierID INT,
ProductName VARCHAR(128),
ProductType VARCHAR(128),
UnitPrice FLOAT,
PRIMARY KEY(ProductID),
FOREIGN KEY(SupplierID) REFERENCES Supplier(SupplierID)
);
CREATE TABLE OrderDetails(
OrderID INT,
ProductID INT,
Quantity INT,
Comment VARCHAR(512),
FOREIGN KEY(OrderID) REFERENCES CustOrder(OrderID),
FOREIGN KEY(ProductID) REFERENCES Product(ProductID)
);
INSERT INTO Customer VALUES(1, 'James Teagan', 'Canada', '(450)567-9876',
'james.teagan');
INSERT INTO Customer VALUES(2, 'Henri Tweed', 'Australia', '(333)543-
2121', 'henri.tweed@hotmail');
INSERT INTO Customer VALUES(3, 'Ronald Sarko', 'Australia', '(333)541-
2212', 'ronald.sarko');
INSERT INTO CustOrder VALUES(1, 1, 5.54, 2016);
INSERT INTO CustOrder VALUES(2, 2, 15.22, 2017);
INSERT INTO CustOrder VALUES(3, 3, 6.72, 2017);
INSERT INTO CustOrder VALUES(4, 2, 10.55, 2017);
INSERT INTO Supplier VALUES(1, 'SpplCo', 'China', '(222)444-7788',
'spplcol', 1956);
INSERT INTO Supplier VALUES(2, 'PLR_inc', 'France', '(456)982-7101',
'PLR_incl', 1931);
INSERT INTO Product VALUES(1000, 1, 'Refrigerator_A1','Appliance',
1199.99);
INSERT INTO Product VALUES(2000, 2, 'Dryer_D4', 'Appliance',949.99);
INSERT INTO OrderDetails VALUES(1, 1000, 3, 'Bring the merchandisein
through the back door.');
INSERT INTO OrderDetails(OrderID, ProductID, Quantity) VALUES(2,2000, 5);
INSERT INTO OrderDetails(OrderID, ProductID, Quantity) VALUES(3,2000, 1);
INSERT INTO OrderDetails(OrderID, ProductID, Quantity) VALUES(4,2000, 1);
2. Then, make queries to the database in order to obtain thefollowing information:
a) The names of the customers that are from Canada.
b) The names of the Australian customers sorted in alphabeticalorder.
c) The IDs of the orders that have a quantity of items inferior orequal to 3.
d) The IDs of the orders that have a quantity of items inferior orequal to 3 and have no comment.
e) The names of the suppliers that have been founded after 1950 orare French suppliers.
f) The names of the suppliers that have been founded after 1950 andare French suppliers.
g) The names of the suppliers that have been founded after 1950 andare Chinese suppliers, or are
Canadian supppliers.
h) The tranport fees of the orders that have a quantity of itemsinferior to 5.
i) The names of the suppliers who sell products with a unit priceof more than $1000.
Step by Step Solution
3.40 Rating (147 Votes )
There are 3 Steps involved in it
Step: 1
a The names of the customers that are from Canada select customername from customer where country li...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