For the following questions, use the relational schema defined as follow. Book B
ID: 3593213 • Letter: F
Question
For the following questions, use the relational schema defined as follow. Book BookCopy(copyNo, ISBN, available) Borrower(borrowerNo, borrowerName, borrowerAddress) BookLoan (copyNo, dateOut, dateDue, borrowerNo) (ISBN, title, author, edition, year) where Book rimary key contains details of book titles in the library and the ISBN is the p contains details of the individual copies of books in the library and copyNo is the primary key. ISBN is a foreign key identifying the book title contains details of library members who can borrow books and borrowerNo is the primary key BookC opy Borrower BookLoancontains details of the book copies that are borrowed by library members and copyNo/dateOut forms the primary key. borrowerNo is a foreign key identifying the borrower. 1. Insert one new row for the BookCopy table 2. List all book titles 3. List all borrower details, in alphabetical order of borrower name List all book titles published in the year 2005 written by "J. K. Rowling". How many copies of ISBN “0-7475-8108-8" are there? List all copies of the book with "Harry Potter" keyword in title that are available for borrowing 4. 5. 6. 7. List the names of borrowers who currently have the book title “Lord of the Rings" on loan 8. List the names of borrowers who will overdue books toda 9. List the top 10 most-borrowed books in the library 10. Modify the address of borrower John Smith to “123 Main Street".Explanation / Answer
7) SELECT borrowerName FROM Borrower WHERE borrowerNo=( SELECT borrowerNo FROM BookLoan WHERE copyNo = (SELECT copyNo from BookCopy WHERE ISBN IN (SELECT ISBN FROM Book WHERE title='Lord of the Rings')));
9) SELECT B.title,B.ISBN,COUNT(SELECT * FROM BookLoan) as NoOfTimesBorrowed
FROM Book B LEFT JOIN BookCopy BC ON B.ISBN=BC.ISBN
GROUP BY B.ISBN
ORDER BY NoOfTimesBorrowed DESC
LIMIT 10;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.