Javascript relational algebra