Working with Connections
Connections in EngramDB allow you to create graph-like relationships between memory nodes. This document explains how to work with connections effectively.What are Connections?
A connection represents a relationship between two memory nodes. Each connection has:- A target memory node ID (the node being connected to)
- A relationship type (e.g., Association, Causation, Sequence)
- A strength value (between 0.0 and 1.0)
- A creation timestamp
Relationship Types
EngramDB provides several built-in relationship types:- Association: A general relationship between related concepts
- Causation: A cause-effect relationship
- Sequence: A temporal sequence or ordering
- Hierarchy: A parent-child or category-subcategory relationship
- Similarity: Indicates that two memories are similar
- Opposition: Indicates that two memories are opposites or contradictory
- Custom: User-defined relationship types
Creating Connections
You can create connections between memory nodes in two ways:- Directly on a memory node
- Through the database API
Using the Memory Node API
Rust Example
Python Example
Using the Database API
Rust Example
Python Example
Retrieving Connections
You can retrieve the connections of a memory node in two ways:- Directly from a memory node
- Through the database API
Using the Memory Node API
Rust Example
Python Example
Using the Database API
Rust Example
Python Example
Removing Connections
You can remove connections in two ways:- Directly from a memory node
- Through the database API
Using the Memory Node API
Rust Example
Python Example
Using the Database API
Rust Example
Python Example
Use Cases for Connections
Knowledge Graphs
Connections can be used to build knowledge graphs that represent relationships between concepts.Causal Chains
Connections can represent cause-effect relationships, forming causal chains.Temporal Sequences
Connections can represent sequences of events or steps.Graph Traversal
You can traverse the graph by following connections from one memory to another.Rust Example
Python Example
Best Practices
When to Use Connections
Use connections when:- You need to represent explicit relationships between memories
- You want to build a knowledge graph
- You need to model causal chains or sequences
- You want to represent hierarchical relationships
Connection Strength
The strength value (0.0 to 1.0) can be used to represent:- The confidence in the relationship
- The importance of the relationship
- The strength of association between concepts

