Question
sql code(named : schema.) : CREATE TABLE Customer (customerNO char(8) NOT NULL PRIMARY KEY, customerName Varchar(20),address Varchar(40), city varchar(20),category Char(2), custBalance Decimal(9,2)); CREATE TABLE Product
sql code(named :schema.):
CREATE TABLE Customer
(customerNO char(8) NOT NULL PRIMARY KEY,
customerName Varchar(20),address Varchar(40),
city varchar(20),category Char(2),
custBalance Decimal(9,2));
CREATE TABLE Product
(productNO Char(10) NOT NULL PRIMARY KEY,
label Varchar(30),
price Decimal(9,2),
QStock Number(11));
CREATE TABLE customerOrder
(orderNO char(8) NOT NULL,orderDate Date,customerNO char(8),
PRIMARY KEY (orderNo),
FOREIGN KEY (customerNo) REFERENCES Customer(customerNo));
CREATE TABLE orderedProduct
(orderNO char(8),
productNO char(10),
orderQuantity Number(11),
FOREIGN KEY (orderNO) REFERENCES customerOrder(orderNO),
FOREIGN KEY (productNo) REFERENCES Product(productNo),
PRIMARY KEY (orderNo, productNo));
INSERT INTO Customer Values ('B062','Ahmed','72 street Freedom','Salalah','B2',-100);
INSERT INTO Customer Values ('B112','Salim','Street Sultan Qaboos','Muscat','C1', 1250);
INSERT INTO Customer Values ('B332','Alia','Building Hana Street Alhisn ','Ibri','B2', 0);
INSERT INTO Customer Values ('B512','Taoufiq','Building Alaamra','Rustaq','B1', -500);
INSERT INTO Customer Values ('C003','Islam','House N 5 Street Asahafa','Salalah','B1', -1000);
INSERT INTO Customer Values ('C123','Murad','Building Asalalm Main Street','Ibri','C1', -2000);
INSERT INTO Customer Values ('C400','Jamilah','Street of garden House n 5','Muscat','B2', 350);
INSERT INTO Product Values ('CS262','Chev.fir 200x6x2',75,45);
INSERT INTO Product Values ('CS264','Chev.fir 200x6x4',120 ,2690);
INSERT INTO Product Values ('CS464','Chev.fir 400x6x4', 220,450);
INSERT INTO Product Values ('PA45','Steel point 45 (1K)', 105,580);
INSERT INTO Product Values ('PA60','Steel point 60 (1K)', 95,134);
INSERT INTO Product Values ('PH222','PL.Hetre 200x20x2', 230,782);
INSERT INTO Product Values ('PS222','PL.fir 200x20x2', 185,1220);
INSERT INTO customerOrder Values (30178,'01-DEC-2017','C400');
INSERT INTO customerOrder Values (30179,'02-DEC-2017','B512');
INSERT INTO customerOrder Values (30182,'03-DEC-2017','C400');
INSERT INTO customerOrder Values (30184,'03-DEC-2017','B062');
INSERT INTO customerOrder Values (30185,'02-JAN-2018','B332');
INSERT INTO customerOrder Values (30186,'02-JAN-2018','C400');
INSERT INTO customerOrder Values (30188,'03-JAN-2018','C003');
INSERT INTO orderedProduct Values ( '30178','CS464', '25');
INSERT INTO orderedProduct Values ( '30179','CS262', '60');
INSERT INTO orderedProduct Values ( '30179','PA60', '20');
INSERT INTO orderedProduct Values ( '30182','PA60', '30');
INSERT INTO orderedProduct Values ( '30184','CS464', '120');
INSERT INTO orderedProduct Values ( '30184','PA45', '20');
INSERT INTO orderedProduct Values ( '30185','CS464', '260');
INSERT INTO orderedProduct Values ( '30185','PA60', '15');
INSERT INTO orderedProduct Values ( '30186','PS222', '600');
INSERT INTO orderedProduct Values ( '30186','PA45', '3');
INSERT INTO orderedProduct Values ( '30188','PA60', '180');
INSERT INTO orderedProduct Values ( '30188','PH222', '92');
UPDATE customer set custbalance=0
WHERE category='C1' AND custbalance<0;
UPDATE orderedproduct set orderquantity=10
WHERE productno ='PA60' AND orderno='30185';
CREATE view orderPerClient as SELECT customername, COUNT(orderNo)as numberOfOrders from customer inner join customerorder on customer.customerno=customerorder.customerno GROUP by customername;
_______________________________________________________________________________________________________________
used Sql code(named:schema.) , and answer the following questions:
1. Write the business rules that are reflected by the schema.
2. Create a Crows Foot ERD that represent the above business rules. Write all appropriate connectivities and cardinalities in the ERD.[2]
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