iBet uBet web content aggregator. Adding the entire web to your favor.
iBet uBet web content aggregator. Adding the entire web to your favor.



Link to original content: https://users.cs.duke.edu/~junyang/ra2/
RA: A Relational Algebra Interpreter

RA: A Relational Algebra Interpreter


Introduction

RA is a simple relational algebra interpreter written in Java. It is built on top of an SQL-based relational database system. It implements relational algebra queries by translating them into SQL queries and executing them on the underlying database system through JDBC. RA is packaged with SQLiteJDBC, so you can use RA as a standalone relational-algebra database system. Alternatively, you can use RA as a relational-algebra frontend to other database systems.


Currently Supported Database Systems


Getting RA

The current version of RA is 2.2b (released Aug. 15, 2014). You can download one of the following:

Or follow the project on GitHub!


Using RA

To run RA, just type "java -jar ra.jar" in the directory containing ra.jar. RA will then by default run on the SQLite database file sample.db (on which query examples below are based). To see more options of running RA, type "java -jar ra.jar -h". Options -i (read commands/queries from a file), -o (log output to a file), and -v (turn on verbose mode) are all pretty useful.

If you want to connect to another database or a different database system, you will find it convenient to write a connection properties file of your own. An example is the file sample.properties. Once you have rolled your own properties file, say PROP_FILE, run RA using "java -jar ra.jar PROP_FILE"; add -P if you prefer typing your password at runtime instead of storing it in the properties file.

Once you are in RA, you will see the ra> prompt. For help, type \help;. You exit RA by issuing the \quit; command. Use the \list; command to see what relations are available for query in your database.

RA supports command-line input history and editing using arrow keys: Up/Down recall previous/next lines, and Left/Right move within the current line.

The simplest relational query you can write is one that returns the content of a relation: Just type relName;, where relName is the name of the relation. Note that every command/operator should start with a backslash (\), and every query/command should be terminated by a semicolon (;).

For most database systems that RA runs on (except MySQL), relation and attribute names are case-insensitive per SQL standard. For example, drink is just as good as DRINK. Attributes can be of a variety of types. Details are not important; just beware that types such as INTEGER, SMALLINT, FLOAT, REAL, DOUBLE, DECIMAL, NUMERIC are for numbers, and CHAR and VARCHAR are for strings.

Here is an example of a complex query, which returns beers liked by those drinkers who do not frequent James Joyce Pub:

\project_{beer} (

  ((\project_{name}          // all drinkers
     Drinker)
   \diff
   (\rename_{name}           // rename so we can diff
      \project_{drinker}     // drinkers who frequent JJP
        \select_{bar = 'James Joyce Pub'}
          Frequents))

  \join_{drinker = name}     /* join with Likes to find beers */

  Likes

);
The syntax is insensitive to white space, and it is fine to enter a query on multiple lines; RA will number the lines (beyond the first one) you enter for the current query. C/C++/Java-style comments (// and /*...*/) are supported.

RA supports the following relational algebra operators:


Known Issues/Limitations


Maintained by Jun Yang