# Relationships

Source: https://docs.rushdb.com/2.x/learn/relationships/

Relationships connect RushDB records into a traversable graph. They are named, directed edges between records — optionally carrying their own [properties](/learn/relationships/relationship-properties) — not foreign-key columns or application-side joins.

You can create relationships explicitly, generate them automatically from nested JSON imports, connect large datasets by matching keys, and filter records by traversing one or more hops inside a `where` clause. Multi-hop traversal is expressed with `$relation.hops` and cycle detection with `$cycle` — see [Where Operators](/learn/search-query/where-operators#variable-length-traversal-hops).

## Choose a Workflow

| Goal                                                  | Guide                                                                                      |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| Attach or detach individual record pairs              | [Connect Records](/learn/relationships/connect-records)                                    |
| Connect many records by matching keys                 | [Bulk Relationships](/learn/relationships/bulk-relationships)                              |
| Store and query data on the edges themselves          | [Relationship Properties](/learn/relationships/relationship-properties)                    |
| Review and approve inferred graph structure           | [Suggested Patterns](/learn/relationships/suggested-patterns)                              |
| Create parent-child edges while importing nested JSON | [Import Data](/learn/records-and-queries/import-data)                                      |
| Filter through related records                        | [Relationship Traversal](/learn/records-and-queries/find-and-query#relationship-traversal) |

## Relationship Sources

| Source                         | What it creates                                                               |
| ------------------------------ | ----------------------------------------------------------------------------- |
| Nested JSON import             | Default parent-to-child edges as RushDB decomposes the payload                |
| `attach` / `detach`            | Explicit edges between known record IDs                                       |
| Bulk relationship APIs         | Edges between matching source and target records                              |
| Approved relationship patterns | Explicit edges inferred from schema structure and reviewed before application |

Relationship types and direction are optional when traversing broadly and explicit when your query needs a specific edge contract.

## Related Sections

- [Records & Queries](/learn/records-and-queries) — store and retrieve the records relationships connect
- [Labeled Meta Property Graph](/learn/records-and-queries/labeled-meta-property-graph) — understand record, property, and relationship layers together
- [SearchQuery Reference](/learn/search-query) — full traversal syntax, including multi-hop (`$relation.hops`) and cycle (`$cycle`) matching
