Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelbaron authored and bchardin committed Apr 15, 2024
0 parents commit ff8e3dd
Show file tree
Hide file tree
Showing 249 changed files with 45,483 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/db
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SHD (rql-backend/shd31)
=======================
Copyright (c) 2007 Takeaki Uno.
See rql-backend/shd31/readme.txt for details.

RQL-API, RQL-Core, RQL-Server, and RQL-UI
=========================================
Copyright (c) 2011-2024 [LIMOS/ISIMA, LIRIS/INSA Lyon, LIAS/ISAE-ENSMA]

These portions of the software are licensed under the terms of the MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# RQL project

RQL (Rule Query Language) is a framework that allows the user to mine dependencies such as association rules, functional dependencies, order dependencies, etc.

This project includes a Web interface to write SQL or RQL queries on top of a local DBMS, and browse generated rules.

You can read more about RQL using the following resources:

- [RQL: A Query Language for Rule Discovery in Databases](https://hal.science/hal-01395083/), a TCS paper, 2017.
- [RQL: An SQL-like Query Language for Discovering Meaningful Rules](https://hal.science/hal-01301091/), an ICDM demo, 2014.
- [Query Rewriting for Rule Mining in Databases](https://hal.science/hal-01339257/), an LML workshop paper, 2013.
- [Armstrong-compliant Logical Query Languages](https://hal.science/hal-00649604/), an LID workshop paper, 2011.


## Software requirements

* [Docker](https://www.docker.com/) (that's all)

RQL building and deployment have been tested on:

* macOS Sonoma (with Docker Desktop),
* Ubuntu 20.04.6 LTS
* Debian 12.5

In fact, any operating system that supports [Docker](https://www.docker.com/) should be able to build RQL.

## Build

```console
$ docker compose build
```

## Run

* Create all containers

```console
$ docker compose up -d
```

* Initialize the database

```console
$ docker exec -i rql_db psql -U postgres < db_init.sql
```

* Open the http://localhost/rql URL with your favorite web browser.
To log in, the default account has credentials admin/adminadmin.

## Example

The following example is based on a sample employee table. It can be created from the RQL main query form, which supports both SQL and RQL queries.

~~~SQL
CREATE TABLE emp (
empno INT,
lastname VARCHAR(20),
workdept VARCHAR(3),
job VARCHAR(20),
educlevel INT,
gender CHAR,
sal INT,
bonus INT,
comm INT,
mgrno INT
);
INSERT INTO EMP VALUES (10, 'SPEN', 'C01', 'FINANCE', 18, 'F', 52750, 500, 4220, 20);
INSERT INTO EMP VALUES (20, 'THOMP', NULL, 'MANAGER', 18, 'M', 41250, 800, 3300, NULL);
INSERT INTO EMP VALUES (30, 'KWAN', NULL, 'FINANCE', 20, 'F', 38250, 500, 3060, 10);
INSERT INTO EMP VALUES (50, 'GEYER', NULL, 'MANAGER', 16, 'M', 40175, 700, 3214, 20);
INSERT INTO EMP VALUES (60, 'STERN', 'D21', 'SALE', 14, 'M', 32250, 500, 2580, 30);
INSERT INTO EMP VALUES (70, 'PULASKI', 'D21', 'SALE', 16, 'F', 36170, 700, 2893, 100);
INSERT INTO EMP VALUES (90, 'HENDER', 'D21', 'SALE', 17, 'F', 29750, 500, 2380, 10);
INSERT INTO EMP VALUES (100, 'SPEN', 'C01', 'FINANCE', 18, 'M', 26150, 800, 2092, 20);
~~~

RQL can then be used to identify dependencies within the data. For instance, the following query identifies functional dependencies.

~~~RQL
FINDRULES
OVER empno, lastname, workdept, job, educlevel, gender, sal, bonus, comm, mgrno
SCOPE t1, t2 emp
CONDITION ON A IS t1.A = t2.A
~~~

![The RQL Web interface](images/rql_web.png)

## User accounts

New user accounts must be added manually.

```console
$ docker exec -i rql_db psql -U postgres -d rql
```

~~~SQL
INSERT INTO users (username, firstname, lastname, hashpassword, isadmin)
VALUES
('jdoe', 'Jane', 'Doe', '<bcrypt hashed password>', FALSE);
~~~

RQL uses the original version of bcrypt hashing with 12 rounds.
Therefore, hashed passwords should be of the form: `$2a$12$...`.

An example of such password is provided at the end of the `db_init.sql` file.

## Acknowledgments

RQL has been partially funded by:

- LIRIS, INSA Lyon and the French National Research Agency (ANR), as part of the DAG project
- CNRS, as part of the Mastodons PetaSky, QualiSky and QDoSSI projects
- LIAS, ISAE-ENSMA and the MIRES research federation

### Historic contributors

* Mickael Baron, LIAS, ISAE-ENSMA
* Nicolas Buisson, LIRIS, INSA Lyon
* Brice Chardin, LIAS, ISAE-ENSMA
* Emmanuel Coquery, LIRIS, Université Claude Bernard Lyon 1
* Benjamin Gouriou, LIMOS, ISIMA
* Marie Pailloux, LIMOS, ISIMA
* Jean-Marc Petit, LIRIS, INSA Lyon
* Bilal Rezkellah, LIAS, ISAE-ENSMA

## Citation

If you use RQL in a scientific publication, please reference the following work:

Chardin, B., Coquery, E., Pailloux, M., & Petit, J.-M. (2017). RQL: A Query Language for Rule Discovery in Databases. Theoretical Computer Science, 658, 357-374.

~~~bibtex
@article{rql2017,
title={RQL: A Query Language for Rule Discovery in Databases},
author={Chardin, Brice and Coquery, Emmanuel and Pailloux, Marie and Petit, Jean-Marc},
journal={Theoretical Computer Science},
volume={658},
pages={357--374},
year={2017},
publisher={Elsevier},
}
~~~
74 changes: 74 additions & 0 deletions db_init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
CREATE DATABASE rql;
\c rql;
CREATE TABLE users
(
userid serial NOT NULL,
username character varying,
firstname character varying,
hashpassword character varying,
lastname character varying,
isadmin boolean,
CONSTRAINT user_pkey PRIMARY KEY (userid),
CONSTRAINT user_username_key UNIQUE (username)
);
CREATE TABLE project
(
projectid serial NOT NULL,
projectname character varying,
creationdate character varying,
userid character varying,
description character varying,
CONSTRAINT project_pkey PRIMARY KEY (projectid),
CONSTRAINT project_userid_fkey FOREIGN KEY (userid)
REFERENCES public.users (username) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
CREATE TABLE database
(
"databaseID" serial NOT NULL,
host character varying,
port integer,
name character varying,
userid character varying,
password character varying,
type character varying,
projectid bigint,
CONSTRAINT database_pkey PRIMARY KEY ("databaseID"),
CONSTRAINT pro FOREIGN KEY (projectid)
REFERENCES public.project (projectid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
CREATE TABLE collaborator
(
collaboratorid serial NOT NULL,
projectid bigint,
userid character varying,
CONSTRAINT collaborator_pkey PRIMARY KEY (collaboratorid),
CONSTRAINT collaborator_projectid_fkey FOREIGN KEY (projectid)
REFERENCES public.project (projectid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT collaborator_userid_fkey FOREIGN KEY (userid)
REFERENCES public.users (username) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
CREATE TABLE favorite
(
favoriteid serial NOT NULL,
description character varying,
query character varying,
creationdate character varying,
projectid bigint,
favoritename character varying,
type character varying,
CONSTRAINT favorite_pkey PRIMARY KEY (favoriteid),
CONSTRAINT favorite_projectid_fkey FOREIGN KEY (projectid)
REFERENCES public.project (projectid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT favorite_favoritename_key UNIQUE (favoritename)
);

INSERT INTO users(
username, firstname, hashpassword, lastname, isadmin)
VALUES ('admin', 'admin', '$2a$12$Cq1GoUaBySCjWBHJJALYNOetItTezPXr1B9JdsLa8xqH5ARVVFplm', 'admin', TRUE);
-- login: admin
-- password: adminadmin
58 changes: 58 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
services:

backend:
container_name: rql_backend
build: rql-backend/
image: rql:backend-1.1.0-SNAPSHOT
depends_on:
- db
networks:
- rqlnetwork

db:
container_name: rql_db
image: postgres:9.6
volumes:
- ./db/rql:/var/lib/postgresql/data
networks:
- rqlnetwork
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres

business_db:
container_name: rql_business_db
image: postgres:9.6
volumes:
- ./db/business:/var/lib/postgresql/data
networks:
- rqlnetwork
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres

frontend:
container_name: rql_frontend
build: rql-ui/
image: rql:frontend-1.1.0-SNAPSHOT
depends_on:
- backend
networks:
- rqlnetwork

web:
container_name: rql_proxy
image: nginx:1.25.4
depends_on:
- frontend
- backend
volumes:
- ./nginx-conf:/etc/nginx/conf.d
ports:
- "80:80"
networks:
- rqlnetwork

networks:
rqlnetwork:
name: rqlnetwork
Binary file added images/rql_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions nginx-conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80;

location /rql/server/ {
proxy_pass http://backend:9992/;
proxy_connect_timeout 3000;
proxy_send_timeout 3000;
proxy_read_timeout 3000;
send_timeout 3000;
}

location /rql/ {
rewrite ^/rql(/.*)$ $1 break;
proxy_pass http://frontend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_connect_timeout 3000;
proxy_send_timeout 3000;
proxy_read_timeout 3000;
send_timeout 3000;
}
}
4 changes: 4 additions & 0 deletions rql-backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/target/
**/.classpath
**/.project
**/.settings
24 changes: 24 additions & 0 deletions rql-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM maven:3.8.6-openjdk-8-slim AS build-java-stage

ADD pom.xml /work/pom.xml
ADD rql-api /work/rql-api/
ADD rql-core /work/rql-core/
ADD rql-server /work/rql-server/
WORKDIR /work

RUN ["mvn", "package","-Dmaven.test.skip=true"]

FROM adoptopenjdk/openjdk8:debian-slim

RUN apt-get update && apt-get install make && apt-get install gcc -y
ADD ["shd31", "/shd31"]
RUN cd /shd31 && make

COPY --from=build-java-stage /work/rql-server/target/classes /work/target/classes
COPY --from=build-java-stage /work/rql-server/target/dependency/*.jar /work/target/dependency/

WORKDIR /work
EXPOSE 9992
ENTRYPOINT ["java", "-cp", "target/classes:target/dependency/*", "fr.ensma.lias.rql.RqlLauncher"]

LABEL maintainer="Mickael BARON and Bilal REZKELLAH"
Loading

0 comments on commit ff8e3dd

Please sign in to comment.