
Patrick B. answered 09/25/20
Math and computer tutor/teacher
primary keys:
Users.userID
Books.bookNumber
UserAddress.userID
CheckOut.checkoutNumber
Review.reviewCode
a. List all the books that have been reviewed.
Listing must include name of book, name of reviewer
and rating.
SELECT Title, reviewerName,Rating
FROM Review JOIN Books
ON Review.bookNumber = Books.bookNumber
b. List all users.
Listing must have names and their addresses.
Select FullName,Address,Town,City
From Users JOIN UserAddress
ON Users.userID = UserAdress.userID
/* If you want only ACTIVE users, then you add the clause
WHERE Enabled=True */
c. List all books that have been returned.
List must include book name, author, borrower’s name
and returned date.
SELECT Title, Author, userName, returnDate
From Checkout Join Books
On checkout.bookNumber = Books.bookNumber
Join Users
On users.userId = Checkout.userID
where len(returnDate)>0
9. Create a report to list all books
that have not been returned. List the
borrower’s name and address. Save as Unreturned Books.
SELECT Title, Author, userName, returnDate
From Checkout Join Books
On checkout.bookNumber = Books.bookNumber
Join Users
On users.userId = Checkout.userID
where len(returnDate)=0