Relation CLI

Relation is a command line program to do Relational Algebra with text files.
Relation can also be used online https://www.belle-nuit.com/relation-js/index.html

This presentation gives you a good start to understand relational algebra and its use with these functions
relation-for-excel-200-presentation.pdf

Video demo of Relationa Algebra Online
https://www.belle-nuit.com/download/relation-demo.mov-1080.mp4

Download

Relation has been written in Javascript.
The binary uses Node.JS with the modules process, readline and fs and was compiled with pkg.

https://www.belle-nuit.com/download/relation.zip (Mac)
https://www.belle-nuit.com/download/relation-linux.zip (Linux, not tested)
https://www.belle-nuit.com/download/relation-win.exe.zip (Windows, not tested)

To be used as ./relation in interactive mode and as .relation -b file.rel in batch mode.

Source Code

Relation is on GitHub https://github.com/bellenuit/Relation

Examples

https://www.belle-nuit.com/download/examples.zip

Read a Relation CLI sample session

Short User guide

The text files can be .csv (comma separated values) and .txt (tab separated values),. both in Unicode UTF 8.

Relation has an interactive shell that allows you to open and save relations

  • read path
  • write path

And to create relations directly

  • relation column (column)*
  • insert field (, field)*

The columns are not typed. They values are either strings or numbers depending on the context.
Any value other than 0 is considered true.

Once you have created the relations, you can make the relational operators

  • select expression
  • project column agregator? (, column agregator?)*
  • union
  • difference
  • join (natural|left|right|outer|leftsemi|rightsemi|leftanti|expression)

Expressions can use

  • columns
  • numbers
  • quoted strings
  • mathematical operators + - / *
  • comparison operators = != < <= >=
  • logical operators and or nor not
  • grouping paranthesis ()

Agregators can be

  • count
  • sum
  • max
  • min
  • avg
  • median

You can use also non-relational non relational operators:

  • extend column expression
  • limit start count
  • order column mode

The order mode can be A, Z (alphabetically normal and reverse), 1, 9 (numerically ascending or descending).

Finally, you can manipulate the operation stack:

  • dup
  • pop
  • swap

And print out the results:

  • print (or p)
  • arity
  • header
  • graph
  • // comment

And view and edit the history to rerun it

  • history
  • edit line newtext
  • run

The history of the command line can be saved as .rel file to be reused.

  • write h.rel
  • read h.rel
  • run