Question: SQL code 1. Create a view named PenguinBooks. It consists of the book code, book title, book type, and book price for every book published

SQL code

1. Create a view named PenguinBooks. It consists of the book code, book title, book type, and book price for every book published by Penguin USA. Display the data in the view. 2. Create a view named Paperback. It consists of the book code, book title, publisher name, branch number, copy number, and price for every book copy that is available in paperback. Display the data in the view. 3. Create a view named BookAuthor. It consists of the book code, book title, book type, author number, first name, last name, and sequence number for each book. Display the data in the view. 4. Create the following indexes. If it is necessary to name the index in your DBMS, use the indicated name. a. Create an index named BookIndex1 on the PublisherName field in the Publisher table. b. Create an index named BookIndex2 on the Type field in the Book table. c. Create an index named BookIndex3 on the BookCode and Type fields in the Book table and list the book codes in descending order. 5. Drop the BookIndex3 index. 6. Specify the integrity constraint that the price of any book must be less than $90. 7. Ensure that the following are foreign keys (that is, specify referential integrity) within the Henry Books database. a. PublisherCode is a foreign key in the Book table. b. BranchNum is a foreign key in the Inventory table. c. AuthorNum is a foreign key in the Wrote table. 8. Add to the Book table a new character field named Classic that is one character in length. 9. Change the Classic field in the Book table to Y for the book titled The Grapes of Wrath. 10. Change the length of the Title field in the Book table to 60. 11. What command would you use to delete the Books table from the Henry Books database? (Do not delete the Book table.) 12. Write a stored procedure that will change the price of a book with a given book code and quality. How would you use this stored procedure to change the price of any copy of book 1351 whose quality is excellent to $22.95? 13. Assume the Branch table contains a column called TotalValue that represents the total price for all books at that branch. Following the style shown in the text, write the code for the following triggers. a. When inserting a row in the Copy table, add the price to the total value for the appropriate branch. b. When updating a row in the Copy table, add the difference between the new price and the old price to the total value for the appropriate branch. c. When deleting a row from the Copy table, subtract the price on the record being deleted from the total value for the appropriate branch. 14. If you are using Access 2010, complete the following steps. a. Add the TotalValue field to the Branch table. Create and run a query on the Copy table to determine the appropriate values for this field, and then update the Branch table with these values. b. Create a data macro associated with the After Insert event for the Copy table to implement the trigger in Step 13a. Test the data macro by adding a record to the Copy table and ensuring that the corresponding branchs total value is updated correctly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!