MC Given following query:
SELECT P1.PRODNR, P1.PRODNAME, S1.SUPNR, S1.PURCHASE_PRICE
FROM PRODUCT P1, SUPPLIES S1
WHERE P1. PRODNR = S1.PRODNR
AND NOT EXISTS
(SELECT *
FROM PRODUCT P2, SUPPLIES S2
WHERE P2.PRODNR = S2.PRODNR
AND P1.PRODNR = P2.PRODNR
AND S1.PURCHASE_PRICE > S2.PURCHASE_PRICE)
Given following statements
- For each product the supplier number is retrieved of the supplier who can supply the product for the cheapest prices
- For each product, the supplier number is retrieved of the supplier who supplies the product for the highest price.
- For each product, exactly one tuple is returned
- For each product, more than one tuple can be returned
Which statements are true? Statements 1 and 3 incorrect Statements 2 and 3 incorrect Statements 2 and 4 incorrect Statements 1 and 4 correct
MC Given the following view definition and update statement:
CREATE VIEW TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY) AS
SELECT PRODNR, PRODNAME, AVAILABLE_QUANTITY
FROM PRODUCT WHERE AVAILABLE_QUANTITY>100
WITH CHECK OPTION
UPDATE TOPPRODUCTS
SET QUANTITY=80
WHERE PRODNR=0153
What will be the result of this? The update will be halted because of the WITH CHECK OPTION. correct The update can be successfully made but only the PRODUCT table will be updated. incorrect The update can be successfully made but only the View will be updated. incorrect The update can be successfully made and both the View and PRODUCT table will be updated. incorrect
MC We want to retrieve the available quantity of each ordered product of supplier Ad Fundum. Which of the following queries is correct? SELECT PRODNR, AVAILABLE_QUANTITY
FROM PRODUCT
WHERE PRODNR IN
(SELECT PRODNR
FROM PO_LINE
WHERE PONR IN
(SELECT PONR
FROM PURCHASE_ORDER
WHERE SUPNRIN
(SELECT SUPNR
FROM SUPPLIER
WHERE SUPNAME='Ad Fundum'))) correct SELECT PRODNR, AVAILABLE_QUANTITY
FROM PRODUCT
WHERE PRODNR =
(SELECT PRODNR
FROM PO_LINE
WHERE PONR =
(SELECT PONR
FROM PURCHASE_ORDER
WHERE SUPNR=
(SELECT SUPNR
FROM SUPPLIER
WHERE SUPNAME='Ad Fundum'))) incorrect SELECT PRODNR, AVAILABLE_QUANTITY
FROM PRODUCT
WHERE PRODNR IN
(SELECT SUPNR
FROM SUPPLIER
WHERE SUPNAME='Ad Fundum') incorrect SELECT PRODNR, AVAILABLE_QUANTITY
FROM PRODUCT
WHERE PRODNR IN
(SELECT PRODNR
FROM PO_LINE AND
SUPNR IN
(SELECT SUPNR
FROM SUPPLIER
WHERE SUPNAME='Ad Fundum') incorrect
MC Given following query:
SELECT P1.PRODNR, P1.PRODNAME, S1.SUPNR, S1.PURCHASE_PRICE
FROM PRODUCT P1, SUPPLIES S1
WHERE P1. PRODNR = S1.PRODNR
AND NOT EXISTS
(SELECT *
FROM PRODUCT P2, SUPPLIES S2
WHERE P2.PRODNR = S2.PRODNR
AND P1.PRODNR = P2.PRODNR
AND S1.PURCHASE_PRICE > S2.PURCHASE_PRICE)
Given following statements- For each product the supplier number is retrieved of the supplier who can supply the product for the cheapest prices
- For each product, the supplier number is retrieved of the supplier who supplies the product for the highest price.
- For each product, exactly one tuple is returned
- For each product, more than one tuple can be returned
Which statements are true? Statements 2 and 3 incorrect Statements 1 and 4 correct Statements 1 and 3 incorrect Statements 2 and 4 incorrect
MC Which of the following queries selects the name of the supplier, corresponding order number and total ordered quantity of the order that has the maximum total quantity ordered. SELECT R1.SUPNAME, POL1.PONR, SUM(POL1.QUANTITY)
FROM SUPPLIER R1, PURCHASE_ORDER PO1, PO_LINE POL1
WHERE R1.SUPNR = PO1. SUPNR AND PO1. PONR = POL1.PONR
GROUP BY POL1. PONR
HAVING SUM(POL1.QUANTITY) >= ALL
(SELECT SUM(POL2.QUANTITY)
FROM SUPPLIER R2, PURCHASE_ORDER PO2, PO_LINE POL2
WHERE R2.SUPNR = PO2.SUPNR AND PO2.PONR = PONR
GROUP BY POL2.PONR) correct SELECT R1.SUPNAME, POL1.PONR, SUM(POL1.QUANTITY)
FROM SUPPLIER R1, PURCHASE_ORDER PO1, PO_LINE POL1
WHERE R1.SUPNR = PO1. SUPNR AND PO1. PONR = POL1.PONR
GROUP BY POL1. PONR
HAVING SUM(POL1.QUANTITY) >= ANY
(SELECT SUM(POL2.QUANTITY
FROM SUPPLIER R2, PURCHASE_ORDER PO2, PO_LINE POL2
WHERE R2.SUPNR = PO2.SUPNR AND PO2.PONR = POL2.PONR
GROUP BY POL2.PONR) incorrect SELECT R1.SUPNAME, POL1.PONR, SUM(POL1.QUANTITY)
FROM SUPPLIER R1, PURCHASE_ORDER PO1, PO_LINE POL1
WHERE R1.SUPNR = PO1. SUPNR AND PO1. PONR = POL1.PONR
GROUP BY POL1. PONR
HAVING SUM(POL1.QUANTITY) <= ANY
(SELECT SUM(POL2.QUANTITY)
FROM SUPPLIER R2, PURCHASE_ORDER PO2, PO_LINE POL2
WHERE R2.SUPNR = PO2.SUPNR AND PO2.PONR = PONR
GROUP BY POL2.PONR) incorrect SELECT R1.SUPNAME, POL1.PONR, SUM(POL1.QUANTITY)
FROM SUPPLIER R1, PURCHASE_ORDER PO1, PO_LINE POL1
WHERE R1.SUPNR = PO1. SUPNR AND PO1. PONR = POL1.PONR
GROUP BY POL1. PONR
HAVING SUM(POL1.QUANTITY) <= ALL
(SELECT SUM(POL2.QUANTITY)
FROM SUPPLIER R2, PURCHASE_ORDER PO2, PO_LINE POL2
WHERE R2.SUPNR = PO2.SUPNR AND PO2.PONR = PONR
GROUP BY POL2.PONR) incorrect
MC Given following query:
SELECT R1.SUPNAME, R1.SUPNR, COUNT(*)
FROM PURCHASE_ORDER PO1, SUPPLIER R1
WHERE PO1.SUPNR = R1.SUPNR
GROUP BY R1.SUPNR
HAVING COUNT(*) >= ALL
(SELECT COUNT(*)
FROM PURCHASE_ORDER PO2, SUPPLIER R2
WHERE PO2.SUPNR = R2.SUPNR
GROUP BY R2.SUPNR)
The query retrieves: The name, number and total outstanding orders of the supplier with the most outstanding orders correct The name, number and total outstanding orders of all suppliers that have outstanding orders, except for the supplier(s) with the least outstanding orders incorrect The name, number and total outstanding orders of all suppliers that have outstanding orders incorrect The name, number and total outstanding orders of the supplier with the least outstanding orders incorrect
MC Given following query:
SELECT P1.PRODNR, P1.PRODNAME, S1.SUPNR, S1.PURCHASE_PRICE
FROM PRODUCT P1, SUPPLIES S1
WHERE P1. PRODNR = S1.PRODNR
AND NOT EXISTS
(SELECT *
FROM PRODUCT P2, SUPPLIES S2
WHERE P2.PRODNR = S2.PRODNR
AND P1.PRODNR = P2.PRODNR
AND S1.PURCHASE_PRICE > S2.PURCHASE_PRICE)
Given following statements- For each product the supplier number is retrieved of the supplier who can supply the product for the cheapest prices
- For each product, the supplier number is retrieved of the supplier who supplies the product for the highest price.
- For each product, exactly one tuple is returned
- For each product, more than one tuple can be returned
Which statements are true? Statements 2 and 4 incorrect Statements 1 and 3 incorrect Statements 2 and 3 incorrect Statements 1 and 4 correct
MC Given the following query:
SELECT PRODNR, AVG(QUANTITY) AS AVG_QUANTITY
FROM PO_LINE
GROUP BY PRODNR
HAVING SUM(QUANTITY < 15)
What is the result? The query returns the PRODNR and average QUANTITY of each purchase order that has less than 15 orders. incorrect The query returns the PRODNR and average QUANTITY of each purchase order that has less than 15 purchase order lines. incorrect The query returns the PRODNR and average QUANTITY of each product that has less than 15 orders. incorrect The query returns the PRODNR and average QUANTITY of each product for which the total ordered quantity is less than 15. correct
MC Given the following query:
SELECT PRODNAME FROM PRODUCT
WHERE PRODNR IN
(SELECT PRODNR FROM SUPPLIES
WHERE SUPNR IN
(SELECT SUPNR FROM SUPPLIER
WHERE SUPCITY = 'New York'))
AND PRODNR IN
(SELECT PRODNR FROM SUPPLIES
WHERE SUPNR IN
(SELECT SUPNR FROM SUPPLIER
WHERE SUPCITY = 'Washington'))
What is the result? The query retrieves the product name of each product that has a supplier in New York or Washington. incorrect The query retrieves the product name of each product along with all possible supplier cities. incorrect The query retrieves the product name of each product that has both a supplier in New York and a supplier in Washington. correct The query incorrectly combines every product name and supplier city. incorrect
MC Given the following view definition and update statement:
CREATE VIEW TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY) AS
SELECT PRODNR, PRODNAME, AVAILABLE_QUANTITY
FROM PRODUCT WHERE AVAILABLE_QUANTITY>100
WITH CHECK OPTION
UPDATE TOPPRODUCTS
SET QUANTITY=80
WHERE PRODNR=0153
What will be the result of this? The update can be successfully made but only the View will be updated. incorrect The update can be successfully made and both the View and PRODUCT table will be updated. incorrect The update can be successfully made but only the PRODUCT table will be updated. incorrect The update will be halted because of the WITH CHECK OPTION. correct