Given the following database: Book(ld : string, Title : string, Publisher : stri
ID: 3596559 • Letter: G
Question
Given the following database:
Book(ld : string, Title : string, Publisher : string)
Branch(BranchId : string, BranchName : string, Address : string)
Author(Bookld : string, Name : string)
BookCopies(Bookld : string, Branchld : string, NumCopies :
1) List the Titles and names of authors of books published by Addison Wesley.
2) For each author, list the name of the author and the total number of books by the author(rename it as numBooks)
3) Find the name of the branch that has over all maximum number of copies of books in the system.
Explanation / Answer
Please find my answer.
Please let me know in case of any issue.
Book(ld : string, Title : string, Publisher : string)
Branch(BranchId : string, BranchName : string, Address : string)
Author(Bookld : string, Name : string)
BookCopies(Bookld : string, Branchld : string, NumCopies :
1) List the Titles and names of authors of books published by Addison Wesley.
SELECT Title, Name
FROM Book, Author
WHERE Bookld == Id AND Publisher not like 'Addison Wesley';
2) For each author, list the name of the author and the total number of books by the author(rename it as numBooks)
SELECT Name, count(Id) as numBooks
FROM Book, Author
WHERE Publisher = Name
GROUP BY Name
3) Find the name of the branch that has over all maximum number of copies of books in the system.
SELECT b.BranchName
FROM Branch b, BookCopies bk
WHERE b.BranchId = bk.BranchId
HAVING bk.NumCopies > max(NumCopies)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.