We read your photo as:

c) The SQL code to populate the tables with 3 records each and one additional record for the Product table is as follows:

Computer Science

ScanSolve AI Answer

c) The SQL code to populate the tables with 3 records each and one additional record for the Product table is as follows:

Company Table Population:

INSERT INTO Company (CompanyID, CompanyName, CompanyQuantity) VALUES ('C01', 'VTX', 12);
INSERT INTO Company (CompanyID, CompanyName, CompanyQuantity) VALUES ('C02', 'TAPT', 34);
INSERT INTO Company (CompanyID, CompanyName, CompanyQuantity) VALUES ('C03', 'PORSH', 22);

Product Table Population (3 records + 1 additional):

INSERT INTO Product (ProductID, ProductName, CostPrice) VALUES ('P01', 'Fans', 500);
INSERT INTO Product (ProductID, ProductName, CostPrice) VALUES ('P02', 'Rice', 9000);
INSERT INTO Product (ProductID, ProductName, CostPrice) VALUES ('P03', 'Leves', 7000);
INSERT INTO Product (ProductID, ProductName, CostPrice) VALUES ('P04', 'Chairs', 1500); -- Additional record

Supplier Table Population:

INSERT INTO Supplier (SuppID, SuppName) VALUES ('S01', 'Tima');
INSERT INTO Supplier (SuppID, SuppName) VALUES ('S02', 'Xofnet');
INSERT INTO Supplier (SuppID, SuppName) VALUES ('S03', 'Tima');

Supplied Table Population:

INSERT INTO Supplied (CompanyID, ProductID, SuppID) VALUES ('C01', 'P03', 'S02');
INSERT INTO Supplied (CompanyID, ProductID, SuppID) VALUES ('C02', 'P01', 'S03');
INSERT INTO Supplied (CompanyID, ProductID, SuppID) VALUES ('C03', 'P02', 'S03');

i) The SQL query to display the Company name, product name, and cost price of products supplied by 'Tima', ordered by company name:

SELECT
    C.CompanyName,
    P.ProductName,
    P.CostPrice
FROM
    Company AS C
JOIN
    Supplied AS S ON C.CompanyID = S.CompanyID
JOIN
    Product AS P ON S.ProductID = P.ProductID
JOIN
    Supplier AS Sup ON S.SuppID = Sup.SuppID
WHERE
    Sup.SuppName = 'Tima'
ORDER BY
    C.CompanyName;

Expected Result:

CompanyNameProductNameCostPrice
PORSHRice9000
TAPTFans500

ii) The SQL code to display the number of companies that supply products that cost above 500

Was this helpful?

Still stuck on this one?

Ask a follow-up, and the answer starts from this question.

Got a different question?Ask your own question