Professional Documents
Culture Documents
NAME: ________________________________________________________
In this lab, our Universe of Discourse is a portion of a (hypothetical) Book Trading database,
used to capture information about books that are owned and traded among college students in IT.
(This is the same database you used for Homework #6.)
Figure 0. ERWin model of Book Trading database (foreign keys included for your
convenience).
1
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
Captured in English, the entities of this Universe of Discourse, and the relationships among
them, can be described like this:
Download and install the BOOK database, if you don’t have it already installed
In MyCourses you will find a script called ‘createBOOK.sql’, download the file to your local
hard drive. Run the ‘createBOOK.sql’ script within MySQL to create the BOOK database.
2
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
1. Count the number of publishers that are in each city, statecode combination. Your output
should match the display given below (including column headings):
+-------------------+-------+
| Location | Count |
+-------------------+-------+
| Boston, MA | 1 |
| Chicago, IL | 3 |
| Hartford, CT | 1 |
| New York, NY | 4 |
| Rochester, MN | 1 |
| Rochester, NY | 2 |
| San Francisco, CA | 1 |
+-------------------+-------+
7 rows in set (0.00 sec)
3
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
2. For EVERY book in the book table, show the title, the count of the number of ratings, the
minimum rating, the maximum rating, and the average rating rounded to the nearest
penny. Your results should be sorted by the count of the number of ratings in descending
order, followed by the average ratings in descending order. Your output should match the
display given below (including column headings):
4
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
3. Show the publisher name and count of books published for those publishers that have
published more than two books. Records should be sorted by the count of books published in
descending order, followed by publisher name in ascending order. Your output should match
the display given below (including column headings):
+----------------------------------+------------+
| Publisher Name | Book Count |
+----------------------------------+------------+
| ReadEmandWeep Romance Publishing | 5 |
| CovertoCover Publishing | 4 |
| EZRead Masterpiece Comics | 3 |
+----------------------------------+------------+
3 rows in set (0.00 sec)
4. Write a query that will select all of the book titles that have “bill” in their name and will
display the title of the book, the length of the title, and the part of the title that follows “bill”.
Your output should match the display given below (including column headings). (HINT: Use
SUBSTR and INSTR.)
+-------------------------------------+--------+------------+
| title | Length | After Bill |
+-------------------------------------+--------+------------+
| Yes! Networking is for Bills Fans | 33 | s Fans |
| How to Keep your Cellular Bill Down | 35 | Down |
| How to Keep your Cable Bill Down | 32 | Down |
+-------------------------------------+--------+------------+
3 rows in set (0.00 sec)
5
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
5. Show a listing of used book titles that are available (used books are found in
ownersbook). A title should only appear once in the listing. Your output should match the
display given below (including column headings):
+-------------------------------------------------+
| title |
+-------------------------------------------------+
| The Shortest Book in the World |
| From the Shores of Lake Erie to IT |
| My Love's at Long Last Lost his Lingering |
| My Love's Last Lingering Lost |
| How to Keep your Cellular Bill Down |
| Yes! Networking is for Bills Fans |
| My Love's Last Longing |
| From Deep in the Heart of Texas to IT |
| How to Keep your Cable Bill Down |
| I Lasted my Love's Last Lingering Longing |
| My Lost Love's Long Last Lingering |
| ER, SOM, NF, DK/NF, SQL, JDBC, ODBC, and RELVAR |
| The Science of Literature Searching |
+-------------------------------------------------+
13 rows in set (0.00 sec)
6
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
Legend:
5 Perfect!
4 Majority is correct
3 Half right
2 Majority is wrong
1 Attempt was made, but very little to count as correct
0 Not done
7
Rochester Institute of Technology
Golisano College of Computing and Information Sciences
Department of Information Technology
Comments: