r/Database • u/skwyckl • May 31 '25
Portable graph database to ship with application?
I am having a very specific issue: I am building a desktop application, until now I have been using SQLite, but as of recently, I have so many relationships, that I think a graph database would be much better as a persistence layer. However, most graph databases are server-based. I have only found a handful that can be considered portable:
Kuzu: https://github.com/kuzudb/kuzu (is the name similarity a coincidence?)
SimpleGraph (SQLite Extension): https://github.com/dpapathanasiou/simple-graph
Of course, XML counts somehow, too, as a graph database, but read-write operations are expensive, especially from file.
Any suggestions on how to proceed? Are the techs above good picks? Should I consider something else?
2
u/strider_2112 May 31 '25
Depends on your query requirements. Kuzu supports cypher and cozo supports datalog. Both of them are good. I have used kuzu for graph analysis and it works really well.
1
u/look May 31 '25 edited May 31 '25
I just started using Kuzu (and Memgraph, but it’s a server-client model, not embedded) for something I’m working on. Kuzu is more of a duckdb for graphs than an SQLite for graphs, though.
I’m not sure those other two projects are still active, but they might still work for you (I have not tried them).
A big question is whether you are doing any “advanced” graph algorithms (pagerank, shortest path, etc) or you just want a data model with less impedance mismatch.
Also, I’m not a huge fan, but if you happen to be using the jvm already for some reason, then neo4j can be used embedded, I believe.
1
1
u/lightningball May 31 '25
Neo4 (and open source forks) can be embedded. Not sure what it would cost. Check out SurrealDB too (Rust, WASM).
1
u/Zealousideal-Ship215 Jun 01 '25
you can store relationships in SQL, it is a relational database after all.
1
u/look Jun 01 '25 edited Jun 01 '25
You can, and in many cases even should, but the difference is in how you query on the relationships, both in the language and the underlying engine implementation.
1
1
1
u/Fit-Presentation-591 Jan 01 '26
You can check out https://github.com/colliery-io/graphqlite as well.
1
u/Lazy-Phrase-1520 Jun 01 '25
I would consider graphs if they support multithreaded writes
1
u/look Jun 01 '25
Kuzu is a multithreaded engine with MVCC transactions supporting concurrent writing threads (in a single process).
For example, you can write a program that creates a single READ_WRITE Database object db that points to ./kuzu-db-dir. Then, you can spawn multiple threads T1, …, Tk, and each Ti obtains a connection from db and concurrently issue read or write queries. This is safe. Every read and write statement in Kuzu is wrapped around a transaction (either automatically or manually by you). Concurrent transactions that operate on the same database ./kuzu-db-dir are safely executed by Kuzu’s transaction manager (i.e., the transaction manager inside db), again as long as those transactions are issued by connections that were created from the same Database object.
1
u/Shot-Ad-6378 Jun 01 '25
How about writing from multiple processes? How is it different from spawning multiple threads in single process?
1
u/look Jun 01 '25 edited Jun 01 '25
Kuzu is an embedded database. You can have multiprocess access in read only mode, but not in read-write mode.
The state needed for multiwriter coordination is in one process, so multithreaded works (because they all share it) but not multiprocess.
It wasn’t designed for that. Its intended use is more like SQLite than Postgres.
If you’re looking for the latter, take a look at Memgraph (it’s not just an in-memory db, despite the name).
1
u/Shot-Ad-6378 Jun 01 '25
Thanks, but shouldn't queing be possible based on if db conn is closed or not? At lib level For eg. by logging queries and executing them asynchronously?
1
u/look Jun 01 '25
Do you mean separate processes waiting for the writing process to close, then acquiring it and writing its buffer, etc?
If so, yes that would be possible, though I’m not sure what the performance would be like.
You could also build a simple client-server model on top of it. Or have a background writing process generate periodic snapshots for multiprocess readers (that’s basically how I use it atm).
1
u/Shot-Ad-6378 Jun 02 '25
Great, thanks
1
u/Public_Highlight9754 Jun 08 '25
Hello. I'm one of the co-founders of Kuzu and I just saw this thread. Just to clarify the model of concurrency: If you have multiple threads of the same process, that obtain their connections from the same Database object, then Kuzu's transaction manager will automatically ensure that the concurrent accesses of these different threads are coordinated safely (and you'll get serializability). If instead, you need multiple separate processes P1, ..., Pk, to access the same database, then you'll need to embed Kuzu in an API server process, and make P1, ..., Pk, access the database through the API server.
I wrote this blog post to explain some of these deployment aspects of in-process/embedded databases: https://www.graphgeeks.org/blog/what-every-developer-needs-to-know-about-in-process-dbmss. The part about "What if You Need a DBMS Server?" is the part that explains this situation.
Hope this helps!
6
May 31 '25
[removed] — view removed comment
0
u/look Jun 01 '25
It’s an embedded use case, so they don’t have to consider scaling and operational issues that normally come up in a traditional relational db vs a nosql db question.
It could be worth using another db for the convenience of using the Cypher query language alone.
3
u/dbxp May 31 '25
Why do you think you need a graph database? They're quite a niche type