Skip to content
All products

Graph

Your data has connections.
Follow them.

Model relationships between records, traverse them with Cypher or the graph API, and explore the paths that connect them.

Customers, orders and products connected by declared relations.Illustrative example
shop namespace7 records · 6 relationships
  • Start hereorder-42
    placed_byMayacustomer-7
    containsTrail runnerproduct-9
  • Orderorder-43
    placed_byMayacustomer-7
    containsDay packproduct-12
  • Orderorder-44
    placed_byLeocustomer-8
    containsTrail runnerproduct-9
Selected order's references Other declared relationships

Turn references into relationships.

An order belongs to a customer. A document covers a topic. Declare those connections and query them alongside the records they describe.

  1. Declare a relation

    Connect a source field to another table's primary key. Row writes maintain the edge indexes for that declared relationship.

  2. Explore the connections

    Start from a record, follow bounded hops and filter the records you reach. Use Cypher or choose a dedicated graph endpoint.

Cypher supports a defined subset. Start traversals with a record's primary key; some algorithms require relations within one table.

Try a bounded traversal
Model the connection

The relationship starts
in your record.

A customer's ID on an order is already a connection. Give that field a named relation so the engine can follow it.

Source fieldshop.orders.customer_id

The value written on each order.

Relation nameplaced_by

The name used in a graph query.

Target keyshop.customers.id

The customer the order points to.

shop.ordersRelation block · TOML
[[relations]]
name = "placed_by"
from_col = "customer_id"
bidirectional = true

[relations.target]
namespace = "shop"
table = "customers"
pk = "id"
Ask a connected question

Choose the method
that fits the question.

A nearby record, a route and an influential node are different questions. Start with the smallest traversal that answers yours.

01

What is connected?

Neighbours and reverse lookups

Follow a declared relation in either configured direction to find adjacent records.

02

How do we get there?

Bounded traversal and paths

Explore a neighbourhood with BFS, or choose a path method for the route you need. Set a depth bound.

03

What patterns emerge?

Ranking and communities

Run PageRank over a nominated set of nodes or evaluate community methods. Check each algorithm's relation requirements first.

Start with one order

Retrieve its customer.

Pin the starting record and return the properties your application needs.

Explore graph queries
MATCH (o:orders {id: 'order-42'})
  -[:placed_by]->(c)
RETURN c.id, c.name;

Why graph on OriginChainDB?

Relationships beside records

Keep business fields and graph relations in one engine, using the same record identities throughout your application.

Define a graph schema

More ways to investigate

Find neighbours and paths, then explore ranking or community algorithms for the questions your relation can answer.

Explore graph methods

Context after retrieval

Follow related people, topics or products after a search result to give your application more useful context.

Explore retrieval patterns

Put it to work.

Model your first connection

Declare source fields, target tables and traversal direction before writing records that form your graph.

Graph schema guide

Choose a graph method

Compare traversal, path, ranking and community endpoints, with request examples and the relation requirements for each.

Graph API reference