RiaGraph

RIAGRAPH DOCUMENTATION

Build with
connected data.

A practical introduction to the engine, its Cypher dialect, and the features that make RiaGraph distinct.

01 / START HERE

Getting started

RiaGraph is an embedded property graph database with a Cypher query interface. It is a fork of Ladybug, itself a fork of Kùzu, and prioritizes quality and reliability.

Choose an installation method below, or browse the release artifacts.

Installation method

Install the Python package from PyPI:

pip install riagraph

Import it in Python as riag.

Build the core library and shell from source:

git clone https://github.com/cntSafety/RiaGraph.git
cd RiaGraph
make release

See the source build guide for prerequisites and build options.

The Node.js package is not yet available on npm. Once published, the planned installation command is:

npm install @riagraph/core

Database compatibility

RiaGraph can read Ladybug and Kùzu databases, but after RiaGraph writes one, Ladybug can no longer open it. Keep a copy if you need to use the original engine.

THE BASICS

The graph model

Nodes represent entities; relationships connect them. Both can carry properties. Tables define the types and properties used by the graph.

CREATE NODE TABLE Person(id INT64, name STRING, PRIMARY KEY(id));
CREATE REL TABLE Knows(FROM Person TO Person);
CREATE (:Person {id: 1, name: 'Ada'});
MATCH (p:Person) RETURN p.name;

For a compact reference to common queries, see the Cypher cheat sheet.

RIAGRAPH FEATURE

Namespaces

A namespace assigns each node and relationship to one logical group. Tables retain a shared schema; namespaces do not create separate databases or physical tables, and they are not an authorization boundary.

CREATE NAMESPACE team_a;
CREATE NODE TABLE Person IN ALL NAMESPACES (
  id INT64 LOCAL PRIMARY KEY, name STRING
);
CREATE (:Person {id: 1, name: 'Ada'}) IN team_a;
USE NAMESPACE team_a;
MATCH (p:Person) RETURN p.name;

Selection and writes

Without a session selection, reads see all namespaces and writes default to the implicit global namespace. A singleton session selection scopes reads and supplies a default write target. Restore unrestricted reads with USE NAMESPACE ALL NAMESPACES. Inline selectors can narrow the scope of individual pattern elements; they cannot broaden a surrounding restriction.

Keys and relationships

Primary keys are global to a table by default; a LOCAL PRIMARY KEY permits the same key in different namespaces. Relationships have their own namespace and can connect nodes in different namespaces. Each path element must be visible in the effective query scope.

Lifecycle

ALTER NAMESPACE team_a RENAME TO team_b preserves identity and membership. Dropping a namespace is restrictive: remove its data and finite table memberships first. namespace(element) returns its name, or NULL for global membership.

Consult the namespace specification for selectors, moves, imports, transaction behavior, and supported integrations.

RIAGRAPH FEATURE

ASSERT

ASSERT condition [AS 'message'] checks an expectation when a statement runs. It passes rows through unchanged; it does not filter rows or create a persistent schema constraint. Only TRUE succeeds: FALSE and NULL both fail.

ASSERT $amount > 0 AS 'Amount must be positive';
MATCH (p:Person)
ASSERT p.age IS NULL OR p.age >= 0 AS 'Invalid age'
RETURN p.name;

Rows and aggregates

A non-aggregate condition is checked for each incoming row; zero rows means no per-row checks. A condition containing an aggregate is checked once over all incoming rows and then passes those rows through. On empty input, count(*) is zero. Aggregate conditions cannot mix row-dependent terms outside the aggregate.

MATCH (p:Person)
ASSERT count(*) > 0 AS 'Expected people'
RETURN p.name;

Failure and transactions

A failed assertion raises an error prefixed Assertion failed:. The statement fails without returning rows. In auto-commit mode its transaction rolls back; in an explicit transaction, the whole transaction rolls back. After a write, use WITH before a following assertion.

See the ASSERT specification for full semantics and examples.

KEEP EXPLORING

Further reading

Cypher cheat sheet · RiaGraph source · Ladybug documentation

Ladybug documentation describes the upstream project; check RiaGraph sources for differences and availability.