GitHub - cozodb/cozo: A general-purpose, transactional, relational database

Cozo is a general-purpose, transactional, relational database that uses Datalog for query, is embeddable, and focuses on graph data and algorithms.

The use cases are interesting. Example:

  • You have a lot of interconnected relations and the usual queries need to relate many relations together. In other words, you need to query a complex graph.
    • An example is a system granting permissions to users for specific tasks. In this case, users may have roles, belong to an organization hierarchy, and tasks similarly have organizations and special provisions associated with them. The granting process itself may also be a complicated rule encoded as data within the database.
    • With a traditional database, the corresponding SQL tend to become an entangled web of nested queries, with many tables joined together, and maybe even with some recursive CTE thrown in. This is hard to maintain, and worse, the performance is unpredictable since query optimizers in general fail when you have over twenty tables joined together.
    • With Cozo, on the other hand, Horn clauses make it easy to break the logic into smaller pieces and write clear, easily testable queries. Furthermore, the deterministic evaluation order makes identifying and solving performance problems easier.

This is exactly what happened when I was developing Simple IoT – a graph structure made relationships a lot easier.

I’ve been seeing references to Datalog a lot lately – LogSeq uses it, as well as Fission’s new database.