Truth saves you even though you're afraid of it, and mendacity destroys you even though you don't see any danger -- Imam Ali
Man is a Tool-using Animal; without tools he is nothing, with tools he is all." --Thomas Carlyle
SpQL is graph abstraction over SQL. Making SQL frictionless by removing the pain of schema changes and bringing the joy of graph theory.
The author found the SQL tables too rigid, and felt something is missing in document-based databases like MongoDB and CouchDB which makes them unconventional to use (not mentioning their wierd query language). At that time, graph databases like Neo4j and ArangoDB made more sense to him. Because his projects were mostly small size, using mentioned databases is not worth it since they require lots of RAM and computational power.
He dreamed of something that is compatible to SQL as it can be used upon SQLite.
Spider (🕷) is well-known instinct which walks on his network (🕸). The network is metaphore for graph. Since its actions/queries is converted to SQL, its name may be mix of these 2 words; Hence SpiderQL or SpQL.
Just converts spql
to sql
language.
It aims to bring best of SQLite, Neo4j, CouchDB together.
To use as server, it is mandatory to provide a config file which is written in TOML format. You can you the one that use for development or you write your own. The values in config file can be overwritten by environment variables or flags which are passed as command line arguemnts.
You can look src/config.nim
to see full list of available configs, but for introduction let's take a look at few of them.
server: ServerConfig(
host: v(ctx, "--host", "SPQL_HOST", "server.host", Host),
port: v(ctx, "--port", "SPQL_PORT", "server.port", Port),
)
The above code says it first looks at if there is any CLI parameter with key of --host
, if not, look for SPQL_HOST
environment variable, if can't find it, then look at server.host
in config file. If still can't find the value, it throws error, saying the config value is missing.
...
In graph theory, there are 2 types of entities: nodes and edges.
A node is something that holds data. Here's the internal structure of a node:
id: int |
tag: string |
data: JSON |
---|---|---|
1 | person | {"name": "Farajollah Salahshoor"} |
2 | person | {"name": "Mostafa Zamani"} |
3 | movie | {"title": "Prophet Joseph"} |
An edge is somehting that relates source node to the target node.
Tt may contain data.
Here's the internal structure of an edge:
id: int | tag: string | data: JSON | source: int | target: int |
---|---|---|---|---|
1 | directed_by | {} | 3 | 1 |
2 | acted_in | {} | 2 | 3 |
The above edge shows following relations:
- ndoe 3 is
directed by
node 1 - node 2 acted in node 3
A tag is similar to table name in SQL or collection in document-based databases. It is indexed and efficient to query about.
see ql.md
...
Here are some of the things that I found worth mentioning.
- https://www.delphitools.info/2021/06/17/sqlite-as-a-no-sql-database/
- https://www.sqlitetutorial.net/sqlite-index/sqlite-drop-index/
- https://database.guide/list-indexes-in-sqlite-database/
- https://stackoverflow.com/questions/12526194/mysql-inner-join-select-only-one-row-from-second-table
- https://sqlite.org/json1.html
- https://github.com/Nhogs/popoto
- https://github.com/arturo-lang/grafito/
- https://github.com/webbery/gqlite
- https://github.com/dpapathanasiou/simple-graph
- CouchDB
- Neo4j
- ArangoDB
- https://github.com/krisajenkins/yesql
- https://antonz.org/sqlean-define/
- https://www.kaggle.com/datasets/amanbarthwal/imdb-movies-data
- https://wiki.postgresql.org/wiki/Sample_Databases
- https://github.com/siara-cc/sakila_sqlite3/
I don't have brain to write more SQLs anymore -- me
Friends don't let friends write SQL -- MongoDB ads, WTF