378
Relations, Functions, and Matrices
Writes
Name
iSBN
Chan, Jimmy
0-364-87547-X
East, Jane
0-56-000142-8
King, Dorothy
0-816-35421-9
King, Dorothy
0-816-88506-0
Kovalsco, Bert
0-816-53705-4
Lau, Won
0-364-87547-X
Nkoma, Jon
0-115-01214-1
7. restrict Author where Country = “U. S.” giving Results7
8. restrict Writes where Name = “Dorothy King” giving Results8
9. restrict Book where Publisher = “Bellman” or Publisher = “Swift Key” giving Results9
10. restrict Book where Publisher = “Harding” and Subject = “Art” giving Results10
11. project Author over Name giving Results11
12. project Author over (Name, Country) giving Results12
13. project Book over (Publisher, Subject) giving Results13
14. project Book over (ISBN, Title, Subject) giving Results14
15. join Book and Writes over ISBN giving Results15
16. join Author and Writes over Name giving Results16
For Exercises 17–23, using the relation tables given before Exercise 7, express each query in relational algebra,
SQL, and relational calculus forms. Also give the result of each query.
17. Give the titles of all books about art.
18. Give the titles of all books published by Harding.
19. Give the names of all authors who publish with Harding.
20. Give the names of all authors who have written nature books.
21. Give the titles of all books written by U.S. authors.
22. Give the titles, ISBNs, and publishers of all art books whose authors live in the United States.
23. Give the authors’ names and book titles for all art books written by English authors.
24. If the tuple
Fleur, Suzanne NULL
gets added to the Author table, write the results of the SQL query
seLeCt Name
FrOM Author
Where Country = “U. S.”
Or Country = NULL;
Relations, Functions, and Matrices
Writes
Name
iSBN
Chan, Jimmy
0-364-87547-X
East, Jane
0-56-000142-8
King, Dorothy
0-816-35421-9
King, Dorothy
0-816-88506-0
Kovalsco, Bert
0-816-53705-4
Lau, Won
0-364-87547-X
Nkoma, Jon
0-115-01214-1
7. restrict Author where Country = “U. S.” giving Results7
8. restrict Writes where Name = “Dorothy King” giving Results8
9. restrict Book where Publisher = “Bellman” or Publisher = “Swift Key” giving Results9
10. restrict Book where Publisher = “Harding” and Subject = “Art” giving Results10
11. project Author over Name giving Results11
12. project Author over (Name, Country) giving Results12
13. project Book over (Publisher, Subject) giving Results13
14. project Book over (ISBN, Title, Subject) giving Results14
15. join Book and Writes over ISBN giving Results15
16. join Author and Writes over Name giving Results16
For Exercises 17–23, using the relation tables given before Exercise 7, express each query in relational algebra,
SQL, and relational calculus forms. Also give the result of each query.
17. Give the titles of all books about art.
18. Give the titles of all books published by Harding.
19. Give the names of all authors who publish with Harding.
20. Give the names of all authors who have written nature books.
21. Give the titles of all books written by U.S. authors.
22. Give the titles, ISBNs, and publishers of all art books whose authors live in the United States.
23. Give the authors’ names and book titles for all art books written by English authors.
24. If the tuple
Fleur, Suzanne NULL
gets added to the Author table, write the results of the SQL query
seLeCt Name
FrOM Author
Where Country = “U. S.”
Or Country = NULL;
