$29
Purpose
In this lab, you are going to practice some of the operators of relational algebra you learned in class. It is going to be a good segue to writing queries in SQL.
Preparation
Download a zip file from Polylearn. The zip file should contain ra.jar and sample.properties.
Starting Up
To start the radb tool type the following command where you placed the ra.jar and sample.properties file (you need to have Java installed on your machine):
java -jar ra.jar sample.properties
(To quit, type \quit;)
The tool is written by a professor at Duke. It does not support all operations of relational algebra and I do not think some of the operators follow the standard precisely in some edge cases. However, it is a good tool for us to practice relational algebra on a database.
Read the online documentation here for usage: https://users.cs.duke.edu/~junyang/ra2/
Exercises
Write the following queries in relational algebra.
1. List the relations available in the database with \list command (6 relations should be available).
2. Print all tuples in Bar.
3. Print all tuples in Beer.
4. Print all tuples in Drinker.
5. Print all tuples in Frequents.
6. Print all tuples in Serves.
7. Print all tuples in Likes.
8. Print all the names of bar Amy frequents.
9. Print all the names of beer Amy likes.
10. Print the name of the bar Ben frequents the most (do not hard code the name of the bar).
11. Print the name(s) of a person/persons who frequents James Joyce Pub the most (Do not hard code the name of drinker).
12. Print the name of the cheapest beer served in town and the name of the bar where it is available (Do not hard code the name of beer).
13. Print the name of beer commonly liked by Amy, Ben, Eve, and Dan (Do not hard code the name of beer).
14. Print the name of beer nobody likes (Do not hard code the name of beer nor the names of drinkers).
Demo your work and copy the relational algebra (2-14) you wrote to a text file and submit it to Polylearn.