Question

7.13. Consider the following View definition and update statement: CREATE VIEW TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY) AS SELEC7.19. Consider the following query: SELECT R1.SUPNAME, R1.SUPNR, COUNT(*) FROM PURCHASE_ORDER PO1, SUPPLIER R1 WHERE PO1.SUPN7.21. Consider following query: SELECT P1.PRODNR, P1.PRODNAME, S1.SUPNR, S1.PURCHASE_PRICE FROM PRODUCT P1, SUPPLIES S1 WHERE

0 0
Add a comment Improve this question Transcribed image text
Answer #1

7.13.Qns: create view TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY)as select PRODNR,PRODNAME,AVAILABLE_QUANTITY from PRODUCT where AVALIABLE_QUANTITY>100 with check option update TOPPRODUCTS set QUANTITY=80 where PRODNR=0153

Result:The update will be halted because of the WITH CHECK OPTION

exp:The following Transact-SQL statement attempting to update data by changing the QUANTITYto 80 of PRODNR=0153 will fail because quantity does not meet the criteria defined in the view. If you did not have WITH CHECK OPTION defined, the UPDATE statement would succeed, and a requery of the view would return no rows. To update the view we must use the following statement

UPDATE VIEW TOPPRODUCTS SET QUANTITY=80 WHERE PRODNR=0153

7.19 Qns: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)

Result:The name,number and total outstanding orders of all suppliers that have outstanding orders

exp:Here in this statement the subquery returns all the suppliers group by SUPNR.from that result The ALL query returns all rows whose values in the column_name ie count are greater than or equal to all the values returned by using the condition specified in the having clause

The HAVING clause retrieves the result for a specific group of a column, which matches the condition specified in the HAVING clause.

7.21 Qns:SELECT P1.PRODNR,P1.PRODNAME,S1.SUPNR,S1.PURCHASE_PRICE FROM PRODUCT P1,SUPPLIES S1 WHERE P1.PRODNR AND NOT EXISTS(SELECT * FROM PRODUCTS P2,SUPPLIES S2 WHERE P2.PRODNR=S2.PRODNR AND P1.PRODNR=P2.PRODNR AND S1.PURCHASE_PRICE>S2.PURCHASE_PRICE)

Ans:option C(2 and 3)

exp:here the sub query returns the supplier name who supplies the product for highest price is reteieved.Then the NOT EXISTS operator returns true if the underlying subquery returns no record. However, if a single record is matched by the inner subquery, the NOT EXISTS operator will return false, and the subquery execution can be stopped.The advantage of using the NOT EXISTS operators is that the inner subquery execution can be stopped as long as a matching record is found.

Add a comment
Know the answer?
Add Answer to:
7.13. Consider the following View definition and update statement: CREATE VIEW TOPPRODUCTS(PRODNR,PRODNAME,QUANTITY) AS SELECT PRODNR, PRODNAME,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Questions in this part ask you to write SQL queriesthat would retrieve certain information from the...

    Questions in this part ask you to write SQL queriesthat would retrieve certain information from the tables. For each question, write the SQL query that would display the information asked by the question. Display information about parts that have their weights greater than the average weight of all parts.   PNO PNAME P2 BOLT P3 SCREW Find supplier numbers who supply any screws (i.e., such that the part name is ‘screw’).  The constraint is that you may not use any join or...

  • Use the give table below to answer the following questions. sName Smith sCity SI S2 PI...

    Use the give table below to answer the following questions. sName Smith sCity SI S2 PI P2 P3 P4 PS Nut Bolt Red Blue 12 17 17 10 Blake Paris Screw Red S4. S5 30 Athens Blue 12 SP SNo (PK) (FK S1 S1 S1 S1 S1 S2 S2 S3 S3 S3 S4 P1 P2 P3 P4 PS PI P2 Pl P2 P3 P2 P3 P4 200 100 100 200 200 200 S5 Table: Content of the Supplier-Parts DB Tables...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT