Skip to content

junjiemars/redisql

Repository files navigation

Redisql

Play Redis as a rational store via SQL

Rules of Design

  • 1st Rule: Redis is just Redis
  • 2nd Rule: See the 1st Rule
  • 3rd Rule: As fast as possible

Play on the Fly

  • How to build:
lein uberjar

or

boot build --pro
  • Run test:
boot test
  • General parser: java -jar <redisql.jar> -e"aaaabbbb" [email protected]
  • Redisql CLI mode: java -jar <redisql.jar> -s"select * from t1;"
  • Redisql REPL mode: java -jar <redisql.jar>

Schemed Redis

  • Implement a set of basic sql semantics
  • Models: single node or master-slave
  • Naming: _{*}_
  • Versioning: think about it in future
  • Clustering: ok, think about it in future
  • row: use Hash reprensents the row
  • column: just as Hash's field
  • cell: the intersect of a row and a column, identified by Hash's field and value pair
  • primary key: one Table one primary key, which identifies a row, use Zset/Set represents it
  • constraints: integrity check, such as not null or default

It's awesome to create table into Redis, and so easy

create table t1 (
  id number(2,0) primary key,
  last_name varchar2(30) not null,
  salary number(4,2) default 0.0);

Somethimes the Identity column is required, so Redisql supports it.

create table t2 (
  id number(2,0) identity,
  last_name varchar2(30) not null,
  salary number(4,2) default 0.0);

Describe schema

How to view the schema, it's a problem, so

describe;
describe t1;
describe t2;

Insert

Just go:

insert into t1(id, last_name, salary) values (101, 'Anny', 1200);
insert into t2(last_name, salary) values('Ben', 1200.50);

Update

Delete

Select

It's a hard job, so I start it with level zero.

  • supports single compare expression
select * from t1 where id=101;
select * from t2 where id >= 101;
select * from t3 where id <= 'aaa';
  • select all
select * from t1;

Query optimizer

Order by

Relations

References

About

Play Redis as a rational store via SQL

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published