Question: Assignment 3 Structured Query Language (SQL) Points: 50 Instructions: For this assignment you must submit a document file (in pdf or doc format) with answers


Assignment 3 Structured Query Language (SQL) Points: 50 Instructions: For this assignment you must submit a document file (in pdf or doc format) with answers to the following questions. Consider the LIBRARY relational database schema description provided below which is used to keep track of books, borrowers, and book loans. The relations are: . BOOK (BookID, Title, PublisherName) BOOK_AUTHORS (BOOKID, AuthorName) PUBLISHER (Name, Address, Phone) BOOK_COPIES (BookID, Branchid, NumberOfCopies) BOOK_LOANS (BookID, Branchid, CardNumber, DateOut, DueDate) LIBRARY_BRANCH (BranchID, BranchName, Address) BORROWER (CardNumber, Name, Address, Phone) . 1. (10 points) Write appropriate SQL DDL statements (CREATE statements) for declaring the above described relational database schema. Specify the keys and referential triggered actions. 2. (5 points each) Write the following queries in SQL, using the schema provided above. (Note: Your queries must not be state-dependent", that is, they should work without modification even if another instance of the database is given.) (a) How many copies of the book titled "The Lost Tribe" are owned by the library branch whose name is "Sharpstown"? (b) How many copies of the book titled "The Lost Tribe" are owned by each library branch? (c) Retrieve the names of all borrowers who do not have any books checked out. (d) For each book that is loaned out from the Sharpstown branch and whose DueDate is prior to "September 1, 2018", retrieve the book title, the borrower's name, and the borrower's address. (e) For each book authored (or coauthored) by Stephen King, retrieve the title and the number of copies owned by the library branch whose name is "Central". (1) Retrieve the names, addresses, and number of books checked out for all borrowers who have more than five books checked out. (9) Retrieve all book titles that are available in "Sharpstown" branch but not in "Morristown branch. (n) Retrieve book titles that are available in all library branches in the database
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
