I need help with this assignment!! Consider a library database with the followin
ID: 3753744 • Letter: I
Question
I need help with this assignment!!
Consider a library database with the following schema (where primary keys are underlined):
Book(bookID, ISBN, title, author, publish-year, category)
Member(memberID, lastname, firstname, address, phone-number, limit) CurrentLoan(memberID, bookID, loan-date, due-date)
History(memberID, bookID, loan-date, return-date)
Members can borrow books from the library. The number of books they can borrow is limited by the “limit” field of the Member relation. The category of a book includes fiction, non-fiction, children’s and reference. The CurrentLoan table represents the information about books that are currently checked out. When the book is returned to the library, the record will be removed from CurrentLoad relation, and will be inserted into History relation with the return-date. A library may have more than one copy of the same book, in which case each copy has its own bookID, but all copies share the same ISBN.
Express each of the following tasks in relational algebra.
(1) (4 pts) Find the memberID, address, and phone-number of John Smith.
(2) (8 pts) List the bookID and title of all the books that are currently checked out by John Smith. Do not use any natural join in this query.
(3) (8 pts) List the bookID and title of all the books that are either currently checked out or borrowed in the past by John Smith.
(4) (6 pts) Find the bookID and title of all the books that are not currently checked out.
(5) (8 pts) List the first and last names of members who have borrowed (either currently or in the past) all the books in the library that are authored by Arthur Miller. If some books authored by Arthur Miller have multiple copies, he or she must have borrowed at least one copy of each of Arthur Miller’s books.
(6) (6 pts) For each member, find the total number of books currently being checked out (write a single query for this question)
Explanation / Answer
Please Note: I have answered the first 4 sub-parts of the Question, as per Chegg Answering Guidelines. For receiving answers on the other Questions, please Re-Post.
Answers)
(1) (4 pts) Find the memberID, address, and phone-number of John Smith.
select memberID, address, phone-number from Member where firstname=’John’ and lastname=’ Smith’;
(2) (8 pts) List the bookID and title of all the books that are currently checked out by John Smith.
Select bookID, title from Book where bookID in (
Select bookID from CurrentLoan where memberID in (
Select memberID from Member where firstname=’John’ and lastname=’ Smith’
)
);
(3) (8 pts) List the bookID and title of all the books that are either currently checked out or borrowed in the past by John Smith.
Select bookID, title from Book where bookID in (
Select bookID from History where memberID in (
Select memberID from Member where firstname=’John’ and lastname=’ Smith’
)
);
(4) (6 pts) Find the bookID and title of all the books that are not currently checked out.
Select bookID, title from Book where bookID not in (
Select bookID from CurrentLoan
);