Michael S McDaniel CS 472 – Henry Books Case Chapter Four 1. Create a view named PengiunBooks. 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. CREATE VIEW PenguinBooks AS SELECT BookCode, Title, Type, Price FROM Book WHERE PublisherCode = "PE"; 2. Create a view named Paperback. It consists of the book code, book title, publisher name, and book price for every book that is available in paperback. Display the data in a view. CREATE VIEW PaperBack AS SELECT Book.BookCode, Book.Title, Publisher.PublisherName, Book.Price FROM Book, Publisher WHERE Book.PublisherCode = Publisher.PublisherCode AND Book.Paperback=TRUE; 3. Create a view named BookInventory. It consists of the book code and the total number of units of the book that are on hand at any branch. Display the data in the view. CREATE VIEW BookInventory AS SELECT Inventory.BookCode, Sum(Inventory.OnHand) AS OnHand FROM Inventory GROUP BY Inventory.BookCode; 4. Create the following indexes. If it is necessary to name the index in your DBMS, a. Create an index named BookIndex1 on the PublisherName field in the Publisher table. CREATE INDEX BookIndex1 ON Publisher (PublisherName); b. Create an index named BookIndex2 on the Type field in the Book table. CREATE INDEX BookIndex2 ON Book (Type); c. Create an index named BookIndex3 on the Type and Price fields in the Book table and list the prices in descending order. CREATE INDEX BookIndex3 ON Book (Type, Price DESC); 5. Drop the BookIndex3 index. DROP TABLE BookIndex3; 6. Specify the integrity constraint that the price of any book must be less than $90.00 CHECK (Book.Price < 90); 7. Ensure that the following are foreign keys (that is, specify referential integrity) within the Henry Books database: (Referential Integrity is the rule that if table A contains a foreign key that matches the primary key of table B, the values of this foreign key must either match the value of the primary key for some row in table B or be null.) a. PublisherCode is a foreign key in the Book table. Let the BOOK table be Table A. PublisherCode is a column in the PUBLISHER table. Call the table PUBLISHER to be Table B. If PublisherCode is a foreign key Table A, then the values of PublisherCode must match those in PublisherCode found in Table A. They do, so PublisherCode is a foreign key in the BOOK table. b. BranchNum is a foreign key in the Inventory table. Let the INVENTORY table be Table A. BranchNum is a column in the BRANCH table, Table B. If BranchNum is a foreign key in Table A, then the values of BranchNum in Table B must match those in BranchNum found in Table A. They do, so BranchNum is a foreign key in the INVENTORY table. c. AuthorNum is a foreign key in the Wrote table. Let the WROTE table be Table A. AuthorNum is a column in the AUTHOR table, Table B. If AuthorNum is a foreign key in Table A, then the values of AuthorNum in Table B must match those in AuthorNum found in Table A. They do, so 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. ALTER TABLE Book ADD Classic CHAR(1); 9. Change the Classic field in the Book table to Y for the book titled The Grapes of Wrath. ALTER TABLE Book WHERE Book.Title = “The Grapes of Wrath” Book.Classic = “Y”; 10. Change the length of the Title field in the Book table to 60. ALTER TABLE Book CHANGE COLUMN Title TO CHAR(60); 11. What command would delete the Books table from the Henry Books database? (do not delete the Book Table). DROP TABLE Books;