npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ra-to-sql

v0.1.4

Published

Really Simple, and quite inefficient, Relational Algebra parser and SQL converter

Downloads

35

Readme

Really Simple (and quite inefficient) Relational Algebra parser and SQL converter

Very simple Relational Algebra to SQL converter. Designed for educational purposes only.

The tool also provides a simple Relational Algebra to LaTeX mathematical expression.

Usage

ra-to-sql can be installed as a Node.js package or as a JavaScript library (see Installation section for more detailed information). The ra-to-sql.js library can be downloaded from here, or used from a CDN https://unpkg.com/ra-to-sql.

As a JavaScript library:

var sql = raToSql.getSQL(<<ra-expression>>);
var latex = raToSql.getLatexExpression(<<ra-expression>>);

As a Node.js app:

var raToSql = require('ra-to-sql');
var sql = raToSql.getSQL(<<ra-expression>>);
var latex = raToSql.getLatexExpression(<<ra-expression>>);

Where <<ra-expression>> is any valid Relational Algebra expression.

Currently, the following operations are supported

  • Rename: Ren[a,b](A), ρ[a,b](A)
  • Projection: Proj[a,b](A), π[a,b](A)
  • Selection: Sel[Condition](A), σ[Condition](A)
  • Cartesian product: A x B, A × B
  • Natural Join A |x| B, A ⋈ B
  • Theta Join A |x(Condition)| B
  • Union: A U B, A ∪ B
  • Intersection: A INT B, A ∩ B
  • Set Difference: A - B
  • Asignment: A <- B
  • Asignment with Rename: A(a,b) <- B

The structure of the language is quite simple, here are a few rules:

  • Operations can be nested
  • There are two types of sentences:
    • Assignments
    • Result (any sentence without an assignment)
  • Parser ends evaluating when a "Result" sentence is found. If no Result sentence is found, the last assignment is considered the Result sentence
  • Semicolon (;) and New Line are both valid as sentence separator

The following are examples of valid set of sentences:

A(a,b) <- Proj[PersonId,PersonName](Person)
A x A x A
OldPeople <- Sel(Age>80)(Person); Person |X| City;
Sel[Number > 14 AND !(Number = 15 OR Number = 18)](Numbers)

You can try it online here:

Note: The SQL generated is compatible with SQL Server and sqlite.

Installation

CDN

<script src="https://unpkg.com/ra-to-sql@<version>/dist/ra-to-sql.js"></script>

Replace <version> with expected version number. For example https://unpkg.com/[email protected]/dist/ra-to-sql.js

Node.js

npm install ra-to-sql

For contrinutors

Pre-requisites

  • Node.js

Setup

Fork/Clone the repository (https://github.com/jrebagliatti/ra-to-sql)

Install the dependencies:

nmp install

Update the code

The following are the main components of the library:

Additionally, the following files are generated as part of the building process:

Running the tests

Tests are defined in the test/test-definitions folder. Each Json file included in that folder becomes a test. File structure is self-explanatory.

Use the following command to run the tests:

npm test

Built With

Contributing

Any contribution is welcomed!. There are no guidelines for contributing, just common-sense.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License.