Lurker News
Hi HN, I have been making this Cozo database since half a year ago, and now it is ready for public release.

My initial motivation is that I want a graph database. Lightweight and easy to use, like SQLite. Powerful and performant, like Postgres. I found none of the existing solutions good enough.
Deciding to roll my own, I need to choose a query language. I am familiar with Cypher but consider it not much of an improvement over CTE in SQL (Cypher is sometimes notationally more convenient, but not more expressive). I like Gremlin but would prefer something more declarative. Experimentations with Datomic and its clones convinced me that Datalog is the way to go.
Then I need a data model. I find the property graph model (Neo4j, etc.) over-constraining, and the triple store model (Datomic, etc.) suffering from inherent performance problems. They also lack the most important property of the relational model: being an algebra. Non-algebraic models are not very composable: you may store data as property graphs or triples, but when you do a query, you always get back relations. So I decided to have relational algebra as the data model.
The end result, I now present to you. Let me know what you think, good or bad, and I'll do my best to address them. This is the first time that I use Rust in a significant project, and I love the experience!

Comments (67) 21 threads

Earlier comments
packetlost#
This is very similar to the goals of a project I've been working on, though I've been focusing on the raw storage format (literally a drop-in replacement for RocksDB, so this could be interesting). I think datalog databases are far underrated.
ithrow1 reply#
you may store data as property graphs or triples, but when you do a query, you always get back relations

Can you elaborate on this? in datomic you can get back hierarchical data

zh217#
I believe you are referring to Datomic's pull syntax (https://docs.datomic.com/on-prem/query/pull.html). The way I see it is that this is an add-on to the query language, not a core part of it, since it applies to the output of the query only. This would be analogous to having a GraphQL server on top of Cozo's relational model. (In fact, in earlier versions of Cozo we did have something like the pull syntax, but we quickly decided that we do not want two distinct ways of querying data in the same database, nor do we want to create a GraphQL clone).

I personally find Datomic's way of doing things a bit too convoluted, as you need to
- learn how to define the schema
- learn how to transact data
- learn how to query data
- learn how to "pull" data after the query is done
and the steps are all very different.

OtomotO1 reply#
Awesome work, congrats.

For someone who never did anything datalog I didn't see an example in the repo and the docs (docs.rs) could need some more content.
I hope to see a 1.0 at some point and performance that can compete with SQLite.
Would love to have an alternative, especially as I have a few pet projects that have graph data (well, in the end the whole universe can be modelled as a graph ;))

zh2172 replies#
I'm very happy that you like it!

The "teasers" section in the repo README contains a few examples. Or you could look at the tutorial (https://nbviewer.org/github/cozodb/cozo-docs/blob/main/tutor...), which contains all sorts of examples.
The Rust documentation on docs.rs could certainly be improved, will do that later!

OtomotO1 reply#
Ah, yes, mea culpa. Was browsing on the phone and did miss that link indeed.

Is is also okay to store big data that would otherwise go into another storage like e.g. blog-posts?
I mean the content could also be modeled as a leaf-node and not be part of the db itself. (not sure if that would be abusing the kv storage)

zh2173 replies#
In short: yes, but not right now. See this issue: https://github.com/cozodb/cozo/issues/2. Also in this case you are not really using it as an embedded database anymore, which is our original motivation. We currently also provide a "cozoserver", but it is pretty primitive at the moment. "Big data" capabilities, when they arrive in Cozo, will probably go into the server instead of the embedded binaries.

Continue this thread — 3 replies

Serow225#
I’m excited to get some more Rust docs!

Even just a pointer to serde ::from_value(value).unwrap(), and ::deserialize(value), would be helpful to get people pointed in the right direction.
Looks like a super cool project, congrats!

dwenzek#
Really nice!

I like the design choices of Datalog for the query language and Relations for the data model. This contrasts with the typical choices made for graph databases where the word graph seems to make links a mandatory query and representation tool.

Load more comments