Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Relational Database Schema for a Library Database: BOOK(BKID, BK_TITLE, BK_LIST_

ID: 3819194 • Letter: R

Question

Relational Database Schema for a Library Database: BOOK(BKID, BK_TITLE, BK_LIST_PRICE, PBID) PUBLISHER(PBID, PB_NAME, PB_STREET, PB_ZIPCODE, PB_PHONE) AUTHOR(AUID, AU_NAME, AU_DOB) LIBRARY_BRANCH(LBID, LB_NAME, LB_STREET, LB_ZIPCODE) BORROWER(CRID, CR_NAME, CR_DOB, CR_STREET, CR_ZIPCODE) ZIPCODE(ZIPCODE, CITY, STATE) BOOK COPIES (BKID, LBID, NO_OF_COPIES) BOOK_AUTHORS(BKID, AUID) For each of the following, write the SQL query: List all the attributes for each Author born after January 18, 1976. List the Name and Date-of Birth for each Author. List the Name and Date-of-Birth for each Author born after January 18, 1976. List the Title, List Price and Publisher's Name for each Book. List the Title, List Price and Publisher's Name for each Book whose List Price is more than $200.000. List the Title, List Price, Author's Name and Publisher's Name for each Book whose List Price is more than $200.00. List the ID, Name, City, State & Zipcode of each Publisher who has published at least one Book whose List Price was more than $200.00. List the number of books, and the minimum, average & maximum List Price for all books. List the Name, and average and maximum book List Price of each Publisher. List number of Publishers who have published at least one Book whose List Price is more than $200.00. List the ID & Name of each Publisher who has never published a Book whose List Price was more than $200.00. List the ID & Name of each Publisher who only publishes Books whose List Price is more than $200.00.

Explanation / Answer

1) SELECT * FROM AUTHOR WHERE AU_DOB > 'JANUARY-18-1976';

2) SELECT AU_NAME, AU_DOB FROM AUTHOR;

3) SELECT AU_NAME, AU_DOB FROM AUTHOR WHERE AU_DOB > 'JANUARY-18-1976';

4) SELECT B.BK_TITLE, B.BK_LIST_PRICE, P.PB_NAME FROM BOOK B, PUBLISHER P WHERE B.PBID = P.PBID;

5) SELECT B.BK_TITLE, B.BK_LIST_PRICE, P.PB_NAME FROM BOOK B, PUBLISHER P WHERE B.PBID = P.PBID AND B.BK_LIST_PRICE > 200.00;

6) SELECT B.BK_TITLE, B.BK_LIST_PRICE, A.AU_NAME,P.PB_NAME FROM BOOK B, BOOK_AUTHORS BA, PUBLISHER P, AUTHOR A WHERE B.PBID = P.PBID AND B.BK_LIST_PRICE > 200.00;

7) SELECT P.PBID,P.PB_NAME,Z.ZIPCODE,Z.CITY.Z.STATE FROM PUBLISHER P, ZIPCODE Z,BOOK WHERE P.ZIPCODE = Z.ZIPCODE AND BOOK.BK_PRICE_LIST >200.00;

8) SELECT COUNT(8), MIN(BK_LIST_PRICE), AVG(BK_LIST_PRICE), MAX(BK_LIST_PRICE) FROM BOOK;

9) SELECT P.PB_NAME, AVG(BK_LIST_PRICE), MAX(BK_LIST_PRICE) FROM BOOK, PUBLISHER P WHERE BOOK.PBID = P.PBID;

10) SELECT COUNT(*) FROM PUBLISHER P, BOOK B WHERE P.PBID = B.PBID AND B.BK_LIST_PRICE > 200.00;

11) SELECT P.PBID, P.PB_NAME FROM PUBLISHER P, BOOK B WHERE P.PBID = B.PBID AND B.BK_LIST_PRICE < 200.00;

12) SELECT P.PBID, P.PB_NAME FROM PUBLISHER P, BOOK B WHERE P.PBID = B.PBID AND B.BK_LIST_PRICE > 200.00;

Thanks...