Querying Using Relational Algebra
Querying Using Relational Algebra
The Author relation gives the author's first and last names and address. Each first name/last name pair is unique.
The Book relation gives the isbn, title, copyright date, publication date, and recommended list price. Since a book
can have multiple authors, the relation BookAuthor matches up authors (identified by name) with books (identified by
ISBN). The Bookstore relation gives the name (key) and address of a book store. The Stock relation gives the
bookstore name, the price, and the ISBN number of the book. listPrice and storePrice are real numbers. copyright
and pubDate are integers (representing the year). All other attributes are strings.
Questions: (Write the answer in relational algebra)
open in browser PRO version
pdfcrowd.com
1.
2.
3.
4.
5.
6.
7.
8.
9.
Return all books (ISBN only) with a list price over $50.
Return all books (ISBN only) with a publish date before Jan. 11, 2001 or whose publisher is 'GenCo'.
Return all addresses (both for authors and bookstores).
Return all authors that have not published a book.
Return the list of books written by Joe Smith.
Return the list of books written by Joe Smith that cost less than $40.
Find all authors (firstName, lastName) who have written books that have been published after Feb. 15, 1990.
Find all authors who have written more than one book.
Find pairs of books with different ISBNs but the same title. A pair should be listed only once; e.g., list (i,j) but
not (j,i).
10. List all the books (ISBN only) that 'All Books' sells that 'Some Books' also sells.
11. List all the books (ISBN only) that 'All Books' sells that 'Some Books' sells for less.
12. Open question: You suggest an English question, and let's try answer it using relational algebra. You do not
have to have an answer to your own question, but hopefully, you think you can answer it. Also, note that we
cannot answer all questions using the subset of relational algebra that we have studied.
Answers:
1.
2.
3.
4.
5.
6.
7.
8.
pdfcrowd.com
pdfcrowd.com
pdfcrowd.com
pdfcrowd.com